alias alldebrid_setup {
set %alldebrid.host api.alldebrid.com
set %alldebrid.port 443
set %alldebrid.apikey xxxxxxx
}
; Main command to unlock a link
alias alldebrid {
if (!$1) { echo -a Usage: /alldebrid <link> | return }
alldebrid_setup
var %path = /v4/link/unlock?agent=script&apikey= $+ %alldebrid.apikey $+ &link= $+ $urlencode($1)
sockopen alldebrid %alldebrid.host %alldebrid.port
hadd -m alldebrid request %path
}
; Open socket connection
on *:sockopen:alldebrid:{
if ($sockerr) {
echo -a Socket error opening connection: $sockerr
return
}
sockwrite -nt $sockname GET $hget(alldebrid,request) HTTP/1.1
sockwrite -nt $sockname Host: api.alldebrid.com
sockwrite -nt $sockname Connection: close
sockwrite -nt $sockname $crlf
}
; Read socket data
on *:sockread:alldebrid:{
if ($sockerr) {
echo -a Socket error reading data: $sockerr
return
}
var %data, %response
sockread -f %data
if (%data) {
bset -t &response $calc($bvar(&response,0) + 1) %data
}
else {
; Full response received, parse it
alldebrid_parse_response &response
btrunc &response 0
}
}
; Parse the response
alias alldebrid_parse_response {
var %json = $bvar($1,1-).text
if (status == success isin %json) {
; Assume JSON parsing here. mIRC doesn't natively support JSON parsing,
; so you might need an external JSON parser or implement basic parsing:
tokenize 44 $gettok(%json,2,123) ; Split by comma, get second token
var %link = $gettok($1,2,58) ; Assuming link is second field after colon
echo -a Successfully unlocked link: %link
}
elseif (status == error isin %json) {
tokenize 44 $gettok(%json,2,123)
var %errorCode = $gettok($1,1,58)
var %errorMessage = $gettok($2,2,58)
echo -a Error from AllDebrid: Code %errorCode - Message %errorMessage
}
else {
echo -a Unexpected response from AllDebrid
}
}
; Close socket
on *:sockclose:alldebrid:{
echo -a AllDebrid connection closed.
}
; Utility function to URL encode
alias urlencode {
var %i = 1, %c, %out
while (%i <= $len($1)) {
%c = $mid($1,%i,1)
if (%c isalnum) %out = %out $+ %c
else %out = %out $+ % $+ $base($asc(%c),10,16,2)
inc %i
}
return %out
}
this code was made by IA ,Doesnt work