Kodi Community Forum
script.module.urlresolver development - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: script.module.urlresolver development (/showthread.php?tid=105707)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28


- k_zeon - 2011-10-30

will take a look at add_directory with infolabels this week. children have been ill and not had much sleep plus programming an app for work. very tired.


- Eldorado - 2011-10-31

Eldorado Wrote:k_zeon - the quick fix in t0mm0's common library to get the infolabels to work:

Open up addon.py and make the following change:

Code:
def unescape(self, text):
        '''
        Decodes HTML entities in a string.
        
        You can add more entities to the ``rep`` dictionary.
        
        Args:
            text (str): String to be cleaned.
            
        Returns:
            Cleaned string.
        '''
        try:
            text = self.decode(text)
            rep = {'&lt;': '<',
                   '&gt;': '>',
                   '&quot': '"',
                   '&rsquo;': '\'',
                   '&acute;': '\'',
                   }
            for s, r in rep.items():
                text = text.replace(s, r)
            # this has to be last:
            text = text.replace("&amp;", "&")
[b]        except TypeError:
            pass[/b]
        return text

Currently it only allows strings to be passed, this will catch and let pass any non-strings

t0mm0, here was the other fix I needed to do for non-text infolabels


- t0mm0 - 2011-10-31

k_zeon Wrote:will take a look at add_directory with infolabels this week. children have been ill and not had much sleep plus programming an app for work. very tired.

i know the tired feeling! no problem, let me know how it goes when you get a chance.

Eldorado Wrote:t0mm0, here was the other fix I needed to do for non-text infolabels

ah yeah, i remember. just committed that (can't think of a better way of doing it).

i also added a new plugin by adq (thanks!) yesterday for vimeo (uses the vimeo addon like the youtube plugin).

t0mm0


- Eldorado - 2011-10-31

Just gave the add_directory with infolabels a try, works good!


- firejackson1 - 2011-11-01

so is this thing anywhere near ready where i could watch megareleas just wondering no rush


- koma85 - 2011-11-01

Hi! i've noticed that the resolution of the megavideo's links are limited to the v0? query:
Code:
r = re.search('//(.+?)/(?:v/|\?v=)([0-9A-Z]+)', url)
But i've also noticed that there are several different links "desination" like d:
Code:
http://www.megavideo.com/?d=CZ8RKCLE

And i would really apreciate an external "txt" reader for the links.
For example:
c:\linkslist.txt
That would be much more simple to edit and test!

I'm a really bad python coder and i'm tryng to make this thing work but seems to be too difficult for me.


- t0mm0 - 2011-11-01

Eldorado Wrote:Just gave the add_directory with infolabels a try, works good!

cool Cool

last night i also added a batch of plugins from MaxMustermann:
  • ecostream
  • stream2k
  • xvidstage
  • videozer
  • uploadc
  • skyload

thanks to max! and there are more on the way Wink

koma85 Wrote:Hi! i've noticed that the resolution of the megavideo's links are limited to the v0? query:
Code:
r = re.search('//(.+?)/(?:v/|\?v=)([0-9A-Z]+)', url)
But i've also noticed that there are several different links "desination" like d:
Code:
http://www.megavideo.com/?d=CZ8RKCLE
yes, i believe that the 'd=' links can also be used with megaupload to give you a higher quality stream. support for that should definitely be added.
koma85 Wrote:And i would really apreciate an external "txt" reader for the links.
For example:
c:\linkslist.txt
That would be much more simple to edit and test!

I'm a really bad python coder and i'm tryng to make this thing work but seems to be too difficult for me.

at the moment i just use the t0mm0.test addon, but it is getting unwieldy. i was thinking last night about including test links in the plugins themselves so the test addon could auto generate all the options - any thoughts?

you can also use strm files i guess, something like:
Code:
plugin://plugin.video.t0mm0.test/?play=true&url=YOUR_URL
would probably do the trick.

t0mm0


- koma85 - 2011-11-01

t0mm0 Wrote:cool Cool

last night i also added a batch of plugins from MaxMustermann:
  • ecostream
  • stream2k
  • xvidstage
  • videozer
  • uploadc
  • skyload

thanks to max! and there are more on the way Wink

yes, i believe that the 'd=' links can also be used with megaupload to give you a higher quality stream. support for that should definitely be added.

at the moment i just use the t0mm0.test addon, but it is getting unwieldy. i was thinking last night about including test links in the plugins themselves so the test addon could auto generate all the options - any thoughts?

you can also use strm files i guess, something like:
Code:
plugin://plugin.video.t0mm0.test/?play=true&url=YOUR_URL
would probably do the trick.

t0mm0

Yeo the D links are meant to the HQ quality, i was thinking that you already have the .strm estension working in xbmc there are any chance to make it automagically parse the hotfile* megavideo* etc link in it? or (maybe simpler idea) create a new .t0mm0 extension as link container. With comma separated values:
Code:
#cat example.t0mm0
http://hotfile.com/filelink?=osdfhjofj;Test 1 film
http://megavideo.com?d=DFGRERW;Cool film n° 2
I've also searched in the web a script that already uses the username/password combination to use the megavideo pro function.
I've found this (i think is in java or similarSmile
Code:
<?xml version="1.0" encoding="utf-8"?>
<WmsMediaItem>
  <ClassID>51</ClassID>
  <ItemID>f30e900e-b24e-40ce-8189-38a773f90544</ItemID>
  <ItemPath>http://www.megavideo.com</ItemPath>
  <ParentID>234DF17B-418C-4FDC-9DFE-CD0C586D2E76</ParentID>
  <Properties>
    <Property>
      <ID>4</ID>
      <Value>MegaVideo</Value>
    </Property>
    <Property>
      <ID>515</ID>
      <Value>1</Value>
    </Property>
    <Property>
      <ID>700</ID>
      <Value>0</Value>
    </Property>
    <Property>
      <ID>701</ID>
      <Value>-1</Value>
    </Property>
    <Property>
      <ID>702</ID>
      <Value>-1</Value>
    </Property>
    <Property>
      <ID>512</ID>
      <Value>0</Value>
    </Property>
    <Property>
      <ID>532</ID>
      <Value>0</Value>
    </Property>
    <Property>
      <ID>553</ID>
      <Value>1</Value>
    </Property>
    <Property>
      <ID>550</ID>
      <Value>const
  WinHttpRequestOption_EnableRedirects = $00000006;
  csUserID = &apos;&apos;;

function HexToBin(const aText: string): string;
var
  i, j, k: Integer;
  sBin: string;
begin
  Result := &apos;&apos;;
  for i := 1 to Length(aText) do begin
    k := StrToInt(&apos;$&apos; + aText[i]);
    sBin := &apos;&apos;;
    for j := 0 to 3 do begin
      if (k and 1) = 1 then
        sBin := &apos;1&apos; + sBin
      else
        sBin := &apos;0&apos; + sBin;
      k := k shr 1
    end;
    Result := Result + sBin
  end
end;

function BinToHex(const aText: string): string;
var
  i, j, k: Integer;
  sBin: string;
begin
  Result := &apos;&apos;;
  i := 1;
  while i &lt; Length(aText) do begin
    sBin := Copy(aText, i, 4);
    k := 0; Inc(i, 4);
    for j := 1 to 4 do begin
      k := k shl 1;
      if sBin[j] = &apos;1&apos; then
        k := k or 1
    end;
    Result := Result + Format(&apos;%x&apos;, [k]);
  end
end;

function XorC(C: Char; aValue: Byte): Char;
begin
  if ((C = &apos;0&apos;) and (aValue = 0)) or ((C = &apos;1&apos;) and (aValue = 1)) then
    Result := &apos;0&apos;
  else
    Result := &apos;1&apos;
end;

var
  bDecrypt: Boolean;
  C: Char;
  WinHttp: Variant;
  iv: array[0..383] of Byte;
  a, b, i, k1, k2: Integer;
  sCrypted, sKey1, sKey2, sServer, sUserID, sVideoID, sVideoInfo, sVideoLink, sVideoPage, sUncrypted: string;
begin
  MediaResourceLink := &apos;&apos;;  
  if WmsRegExMatch(&apos;http://www.megavideo.com/\?v=(.*)&apos;, mpFilePath, sVideoID) then begin  
    bDecrypt := False;
    if csUserID = &apos;&apos; then    
      WmsRegExMatch(&apos;flashvars.userid = "(.*?)"&apos;, WmsDownloadUrl(mpFilePath), sUserID)      
    else    
      sUserID := csUserID;      
    if sUserID &lt;&gt; &apos;&apos; then
      sVideoInfo := WmsDownloadUrl(&apos;http://www.megavideo.com/xml/player_login.php?u=&apos; + sUserID + &apos;&amp;v=&apos; + sVideoID)      
    else
      sVideoInfo := WmsDownloadUrl(&apos;http://www.megavideo.com/xml/videolink.php?v=&apos; + sVideoID);    
    if WmsRegExMatch(&apos;downloadurl="(.*?)"&apos;, sVideoInfo, sVideoLink) then
      MediaResourceLink := WmsHttpDecode(sVideoLink)
    else if WmsRegExMatch(&apos; hd_url="(.*?)"&apos;, sVideoInfo, sVideoLink) then
      MediaResourceLink := WmsHttpDecode(sVideoLink)
    else if WmsRegExMatch(&apos; hd_k1="(\d+)"&apos;, sVideoInfo, sKey1) and
       WmsRegExMatch(&apos; hd_k2="(\d+)"&apos;, sVideoInfo, sKey2) and      
       WmsRegExMatch(&apos; hd_un="(.*?)"&apos;, sVideoInfo, sCrypted) and      
       WmsRegExMatch(&apos; hd_s="(.*?)"&apos;, sVideoInfo, sServer) then        
      bDecrypt := True      
    else if WmsRegExMatch(&apos; k1="(\d+)"&apos;, sVideoInfo, sKey1) and
       WmsRegExMatch(&apos; k2="(\d+)"&apos;, sVideoInfo, sKey2) and      
       WmsRegExMatch(&apos; un="(.*?)"&apos;, sVideoInfo, sCrypted) and      
       WmsRegExMatch(&apos; s="(.*?)"&apos;, sVideoInfo, sServer) then        
      bDecrypt := True;
    if bDecrypt then begin        
      k1 := StrToInt(sKey1);
      k2 := StrToInt(sKey2);
      sUncrypted := HexToBin(sCrypted);
      for i := 0 to 383 do begin
        k1 := (k1 * 11 + 77213) mod 81371;
        k2 := (k2 * 17 + 92717) mod 192811;
        iv[i] := (k1 + k2) mod 128;
      end;
      for i := 256 downto 0 do begin
        a := iv[i];
        b := i mod 128;
        C := sUncrypted[a + 1];
        sUncrypted[a + 1] := sUncrypted[b + 1];
        sUncrypted[b + 1] := c
      end;
      for i := 1 to 128 do
        sUncrypted[i] := XorC(sUncrypted[i], iv[i + 255] and 1);
      MediaResourceLink := &apos;http://www&apos; + sServer + &apos;.megavideo.com/files/&apos; + LowerCase(BinToHex(sUncrypted)) + &apos;/&apos;;      
    end
  end    
end.</Value>
    </Property>
    <Property>
      <ID>551</ID>
      <Value>PascalScript</Value>
    </Property>
    <Property>
      <ID>570</ID>
      <Value>0</Value>
    </Property>
  </Properties>
  <ChildItems></ChildItems>
</WmsMediaItem>
The variable csUserID is gained loggin manually for the first time in any megavideo page and watching the code searching this line:
Code:
flashvars.userid = "OHM.yallahyakkahyallah";
Nod


- koma85 - 2011-11-01

Noticed html codes in the code snip:
cleaned
Code:
<?xml version="1.0" encoding="utf-8"?>
<WmsMediaItem>
  <ClassID>51</ClassID>
  <ItemID>f30e900e-b24e-40ce-8189-38a773f90544</ItemID>
  <ItemPath>http://www.megavideo.com</ItemPath>
  <ParentID>234DF17B-418C-4FDC-9DFE-CD0C586D2E76</ParentID>
  <Properties>
    <Property>
      <ID>4</ID>
      <Value>MegaVideo</Value>
    </Property>
    <Property>
      <ID>515</ID>
      <Value>1</Value>
    </Property>
    <Property>
      <ID>700</ID>
      <Value>0</Value>
    </Property>
    <Property>
      <ID>701</ID>
      <Value>-1</Value>
    </Property>
    <Property>
      <ID>702</ID>
      <Value>-1</Value>
    </Property>
    <Property>
      <ID>512</ID>
      <Value>0</Value>
    </Property>
    <Property>
      <ID>532</ID>
      <Value>0</Value>
    </Property>
    <Property>
      <ID>553</ID>
      <Value>1</Value>
    </Property>
    <Property>
      <ID>550</ID>
      <Value>const
  WinHttpRequestOption_EnableRedirects = $00000006;
  csUserID = '';

function HexToBin(const aText: string): string;
var
  i, j, k: Integer;
  sBin: string;
begin
  Result := '';
  for i := 1 to Length(aText) do begin
    k := StrToInt('$' + aText[i]);
    sBin := '';
    for j := 0 to 3 do begin
      if (k and 1) = 1 then
        sBin := '1' + sBin
      else
        sBin := '0' + sBin;
      k := k shr 1
    end;
    Result := Result + sBin
  end
end;

function BinToHex(const aText: string): string;
var
  i, j, k: Integer;
  sBin: string;
begin
  Result := '';
  i := 1;
  while i < Length(aText) do begin
    sBin := Copy(aText, i, 4);
    k := 0; Inc(i, 4);
    for j := 1 to 4 do begin
      k := k shl 1;
      if sBin[j] = '1' then
        k := k or 1
    end;
    Result := Result + Format('%x', [k]);
  end
end;

function XorC(C: Char; aValue: Byte): Char;
begin
  if ((C = '0') and (aValue = 0)) or ((C = '1') and (aValue = 1)) then
    Result := '0'
  else
    Result := '1'
end;

var
  bDecrypt: Boolean;
  C: Char;
  WinHttp: Variant;
  iv: array[0..383] of Byte;
  a, b, i, k1, k2: Integer;
  sCrypted, sKey1, sKey2, sServer, sUserID, sVideoID, sVideoInfo, sVideoLink, sVideoPage, sUncrypted: string;
begin
  MediaResourceLink := '';  
  if WmsRegExMatch('http://www.megavideo.com/\?v=(.*)', mpFilePath, sVideoID) then begin  
    bDecrypt := False;
    if csUserID = '' then    
      WmsRegExMatch('flashvars.userid = "(.*?)"', WmsDownloadUrl(mpFilePath), sUserID)      
    else    
      sUserID := csUserID;      
    if sUserID <> '' then
      sVideoInfo := WmsDownloadUrl('http://www.megavideo.com/xml/player_login.php?u=' + sUserID + '&v=' + sVideoID)      
    else
      sVideoInfo := WmsDownloadUrl('http://www.megavideo.com/xml/videolink.php?v=' + sVideoID);    
    if WmsRegExMatch('downloadurl="(.*?)"', sVideoInfo, sVideoLink) then
      MediaResourceLink := WmsHttpDecode(sVideoLink)
    else if WmsRegExMatch(' hd_url="(.*?)"', sVideoInfo, sVideoLink) then
      MediaResourceLink := WmsHttpDecode(sVideoLink)
    else if WmsRegExMatch(' hd_k1="(\d+)"', sVideoInfo, sKey1) and
       WmsRegExMatch(' hd_k2="(\d+)"', sVideoInfo, sKey2) and      
       WmsRegExMatch(' hd_un="(.*?)"', sVideoInfo, sCrypted) and      
       WmsRegExMatch(' hd_s="(.*?)"', sVideoInfo, sServer) then        
      bDecrypt := True      
    else if WmsRegExMatch(' k1="(\d+)"', sVideoInfo, sKey1) and
       WmsRegExMatch(' k2="(\d+)"', sVideoInfo, sKey2) and      
       WmsRegExMatch(' un="(.*?)"', sVideoInfo, sCrypted) and      
       WmsRegExMatch(' s="(.*?)"', sVideoInfo, sServer) then        
      bDecrypt := True;
    if bDecrypt then begin        
      k1 := StrToInt(sKey1);
      k2 := StrToInt(sKey2);
      sUncrypted := HexToBin(sCrypted);
      for i := 0 to 383 do begin
        k1 := (k1 * 11 + 77213) mod 81371;
        k2 := (k2 * 17 + 92717) mod 192811;
        iv[i] := (k1 + k2) mod 128;
      end;
      for i := 256 downto 0 do begin
        a := iv[i];
        b := i mod 128;
        C := sUncrypted[a + 1];
        sUncrypted[a + 1] := sUncrypted[b + 1];
        sUncrypted[b + 1] := c
      end;
      for i := 1 to 128 do
        sUncrypted[i] := XorC(sUncrypted[i], iv[i + 255] and 1);
      MediaResourceLink := 'http://www' + sServer + '.megavideo.com/files/' + LowerCase(BinToHex(sUncrypted)) + '/';      
    end
  end    
end.</Value>
    </Property>
    <Property>
      <ID>551</ID>
      <Value>PascalScript</Value>
    </Property>
    <Property>
      <ID>570</ID>
      <Value>0</Value>
    </Property>
  </Properties>
  <ChildItems></ChildItems>
</WmsMediaItem>



- MaxMustermann - 2011-11-01

@t0mm0: Do you plan on integrating a download option (jdownloader/direct)? I have something like that in my xStream addon. Shall I convert it for the urlresolver or common script?

EDIT: Maybe a separate script like script.module.downloader would be a better place?


- koma85 - 2011-11-01

Got it!
Code:
http://www.megavideo.com/xml/player_login.php?u=OHM.PREMIUMCOOKIENUMBER&v=35SJJW7E

and it reply with the download url directly in the html source:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<user type="premium" user="koma85" downloadurl="http%3A%2F%2Fwww299.megavideo.com%2Ffiles%2Ff75d1yahtta901af6cxbgcb%2FDrawn+Together+3x08+-+Persi+Nel+Parcheggio+Parte+2.avi" />



- t0mm0 - 2011-11-01

MaxMustermann Wrote:@t0mm0: Do you plan on integrating a download option (jdownloader/direct)? I have something like that in my xStream addon. Shall I convert it for the urlresolver or common script?

EDIT: Maybe a separate script like script.module.downloader would be a better place?

yeah, maybe you are right and it would be better to make it a separate module. happy to talk about how it would look though if you want?

t0mm0


- t0mm0 - 2011-11-01

koma85 Wrote:Got it!
Code:
http://www.megavideo.com/xml/player_login.php?u=OHM.PREMIUMCOOKIENUMBER&v=35SJJW7E

and it reply with the download url directly in the html source:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<user type="premium" user="koma85" downloadurl="http%3A%2F%2Fwww299.megavideo.com%2Ffiles%2Ff75d1yahtta901af6cxbgcb%2FDrawn+Together+3x08+-+Persi+Nel+Parcheggio+Parte+2.avi" />

cool. the current megavideo code could perhaps be expanded to add login info? the code is from here so we should contribute it back if we add anything (though sadly there is no git or svn available it seems).

i think also that if it is a 'd=' link, you can just change the domain to megaupload and get the original file even if you are not a premium member which might also be useful (though i haven't seen too many megavideo d links in the wild and i haven't seen anywhere a way of converting from v to d links...)

t0mm0


- MaxMustermann - 2011-11-01

t0mm0 Wrote:yeah, maybe you are right and it would be better to make it a separate module. happy to talk about how it would look though if you want?

t0mm0

These are the current xStream functions for direct download and download via jDownloader.
Module settings should look like this:
  • folder: default download path
  • bool: use default path -> if false: ask
  • jDownloader
    • bool: jd_enabled
    • text: jd_host (default=127.0.0.1)
    • text: jd_port (default=10025)
    • bool: jd_automatic_start
    • bool: jd_grabber



- t0mm0 - 2011-11-01

MaxMustermann Wrote:These are the current xStream functions for direct download and download via jDownloader.
Module settings should look like this:
  • folder: default download path
  • bool: use default path -> if false: ask
  • jDownloader
    • bool: jd_enabled
    • text: jd_host (default=127.0.0.1)
    • text: jd_port (default=10025)
    • bool: jd_automatic_start
    • bool: jd_grabber

API looks simple enough for even me to use Wink

with regard to the settings, does anyone know if it is possible to call one addons settings from a button in another addons settings (if that makes sense!)? that would save having lots of settings links in the addon itself...

t0mm0