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


- t0mm0 - 2011-09-14

so i have pushed a new branch in urlresolver called videoid. i haven't updated the docs yet as i don't know if this is the best way to go yet, please read below to see what is going on. i have only updated the putlocker/sockshare plugin.

it adds some complication to the situation, but it also add some flexibility so i'd like to know what people think and whether i should move to this method instead of the existing way of doing things.

it should solve some problems people have had (such as being able to pass a host and media id instead of a full url for example) and although i haven't yet aded it, this will also mean it is easy to sort the choose_source() stuff as it can now be a list of HostdMediaFile objects instead of the current dictionary.

a new object is introduced called HostedMediaFile which represents a (surprise!) hosted media file, check it out here

you make one by passing either a url or a host and a media id:
Code:
f = urlresolver.HostedMediaFile(url='http://www.putlocker.com/file/DFE7599AE064911A')
or
Code:
f = urlresolver.HostedMediaFile(host='putlocker.com', media_id='DFE7599AE064911A')
are equivalent.

add_video_item() has been changed slightly to allow you to pass anything you like. play is now a dict. so you can pass url, or host and media_id (or anything else you like - should fix eldorados problem)

rather than calling a function i urlresolver, you now call the resolve method on your HostedMediaFile. so t0mm0 test addon has been modified thus:
Code:
if play:
    url = addon.queries.get('url', None)
    host = addon.queries.get('host', None)
    media_id = addon.queries.get('media_id', None)
    stream_url = urlresolver.HostedMediaFile(url=url, host=host, media_id=media_id).resolve()
    addon.resolve_url(stream_url)

so, plugins also become slightly more complicated as you have to implement 2 more methods though they are pretty straightforward.

get_url() turns a host and media_id into a proper url for the hoster. in putlicker it goes like this:

Code:
def get_url(self, host, media_id):
        if not host.startswith('www.'):
            host = 'www.' + host
        return 'http://%s/file/%s' % (host, media_id)


get_host_and_id() does the exact opposite - putlocker implementation follows:

Code:
def get_host_and_id(self, url):
        r = re.search('//(.+?)/(?:file|embed)/([0-9A-Z]+)', url)
        if r:
            return r.groups()
        else:
            return False

valid_url() also has to be updated to check for either valid url or host:
Code:
def valid_url(self, hosted_media_file):
        return (re.match('http://(www.)?(putlocker|sockshare).com/(file|embed)' +
                         '/[0-9A-Z]+', hosted_media_file.get_url()) or
                hosted_media_file.get_host().find('putlocker.com') > -1 or
                hosted_media_file.get_host().find('sockshare.com') > -1)
(must be able to make that neater?)

get_media_url now takes host and media_id arguments instead of url, you can get the url by doing self.get_url(host, media_id)

i hope that all makes sense. please take a look and tell me where i am going wrong, and if you think it is worth making these alterations. it certainly solves a fair few problems but i don't want to end up making everything much more complicated!

t0mm0


- Eldorado - 2011-09-14

t0mm0 Wrote:so i have pushed a new branch in urlresolver called videoid. i haven't updated the docs yet as i don't know if this is the best way to go yet, please read below to see what is going on. i have only updated the putlocker/sockshare plugin.

it adds some complication to the situation, but it also add some flexibility so i'd like to know what people think and whether i should move to this method instead of the existing way of doing things.

it should solve some problems people have had (such as being able to pass a host and media id instead of a full url for example) and although i haven't yet aded it, this will also mean it is easy to sort the choose_source() stuff as it can now be a list of HostdMediaFile objects instead of the current dictionary.

a new object is introduced called HostedMediaFile which represents a (surprise!) hosted media file, check it out here

you make one by passing either a url or a host and a media id:
Code:
f = urlresolver.HostedMediaFile(url='http://www.putlocker.com/file/DFE7599AE064911A')
or
Code:
f = urlresolver.HostedMediaFile(host='putlocker.com', media_id='DFE7599AE064911A')
are equivalent.

add_video_item() has been changed slightly to allow you to pass anything you like. play is now a dict. so you can pass url, or host and media_id (or anything else you like - should fix eldorados problem)

rather than calling a function i urlresolver, you now call the resolve method on your HostedMediaFile. so t0mm0 test addon has been modified thus:
Code:
if play:
    url = addon.queries.get('url', None)
    host = addon.queries.get('host', None)
    media_id = addon.queries.get('media_id', None)
    stream_url = urlresolver.HostedMediaFile(url=url, host=host, media_id=media_id).resolve()
    addon.resolve_url(stream_url)

so, plugins also become slightly more complicated as you have to implement 2 more methods though they are pretty straightforward.

get_url() turns a host and media_id into a proper url for the hoster. in putlicker it goes like this:

Code:
def get_url(self, host, media_id):
        if not host.startswith('www.'):
            host = 'www.' + host
        return 'http://%s/file/%s' % (host, media_id)


get_host_and_id() does the exact opposite - putlocker implementation follows:

Code:
def get_host_and_id(self, url):
        r = re.search('//(.+?)/(?:file|embed)/([0-9A-Z]+)', url)
        if r:
            return r.groups()
        else:
            return False

valid_url() also has to be updated to check for either valid url or host:
Code:
def valid_url(self, hosted_media_file):
        return (re.match('http://(www.)?(putlocker|sockshare).com/(file|embed)' +
                         '/[0-9A-Z]+', hosted_media_file.get_url()) or
                hosted_media_file.get_host().find('putlocker.com') > -1 or
                hosted_media_file.get_host().find('sockshare.com') > -1)
(must be able to make that neater?)

get_media_url now takes host and media_id arguments instead of url, you can get the url by doing self.get_url(host, media_id)

i hope that all makes sense. please take a look and tell me where i am going wrong, and if you think it is worth making these alterations. it certainly solves a fair few problems but i don't want to end up making everything much more complicated!

t0mm0

On the cover this sounds very good, don't be too concerned about adding some complexity as it's tough to expand the features while keeping the coding simple

I'll create a 2nd branch in my addon as well and give this a go and let you know how I make out!


- whufclee - 2011-09-14

Hi guys only me popping my head in again - I've just made a new discovery so thought I'd share it with you clever people. By complete accident I came across the Stagevu plugin from AJ's repo and installed it on the xbox and Win7 setup, not only does it work great but it has a great feature that maybe you could use... As well as download, download with jdownloader and download & play (which I believe needs a patched version of xbmc to work) it has "download quietly". This downloads in the background so you can carry on using xbmc as normal, you can even set another download off and have simultaneous downloads or you can watch a stream whilst it's downloading. I've tested this and honestly it really does work - even on xbox, I can't quite believe it! On xbox I tried downloading from stagevu whilst streaming from icefilms and it was great, I could even download from icefilms & stagevu at the same time or do simultaneous downloads from stagevu. Who is this AJ? I'm very impressed!


- k_zeon - 2011-09-16

Hi t0mm0

just tried the megaupload link in your test addon and it fails.
I saw that you had some code somewhere to wait the 45 secs.
Is there an example and how to use it.

tks


- t0mm0 - 2011-09-16

k_zeon Wrote:Hi t0mm0

just tried the megaupload link in your test addon and it fails.
I saw that you had some code somewhere to wait the 45 secs.
Is there an example and how to use it.

tks

sorry, i think the update i committed the other day from anarchintosh may have broken it and i didn't test fully, you could always try going back before that commit. i will try and fix that tomorrow when i also intend to move the countdown code to t0mm0.common.addon

for an example of how to use it see the megaupload plugin

thanks,

t0mm0


- k_zeon - 2011-09-16

Hi t0mm0

went back to Sep 03 and still has wont play that megaload link

I deleted all the folder from Apptle TV2 of yours , then put the sept 03 ones back and set correct permissions etc

Is there any other module i am maybe missing


- rogerthis - 2011-09-16

Did you try a different url, the one in the t0mm0.test is not working http://www.megaupload.com/?d=TQPQJM5H


- Eldorado - 2011-09-16

Looking to do another site as I'm starting to have some fun now Smile

Anyone currently working on either of these sites:

http://www.movie2k.to
http://www.quicksilverscreen.im

I really like quicksilverscreen and might jump on that one first if no one else has?


- rogerthis - 2011-09-16

Eldorado Wrote:Looking to do another site as I'm starting to have some fun now Smile

Anyone currently working on either of these sites:

http://www.movie2k.to
http://www.quicksilverscreen.im

I really like quicksilverscreen and might jump on that one first if no one else has?

I started quicksilverscreen, but I'm really swamped with work for the next month. So no problem.

There isn't a full link url for the play files, but you will find the info below the body.

eg
Code:
</body>
</html><input type="hidden" value="f8147v6ksjv7" id="vid" />
<input type="hidden" value="vidxden" id="vhost" />



- slyi - 2011-09-17

I was playing with an ice resolver http://dl.dropbox.com/u/6589941/icefilms_resolver/icefilms.py.txt (it works for TV) but i dont use the standard url calls to be able to use the net class. Is this allowable?
Sample app http://dl.dropbox.com/u/6589941/icefilms_resolver/plugin.video.t0mm0.icefilms2.zip


- t0mm0 - 2011-09-17

hi,

slyi Wrote:I was playing with an ice resolver http://dl.dropbox.com/u/6589941/icefilms_resolver/icefilms.py.txt (it works for TV) but i dont use the standard url calls to be able to use the net class. Is this allowable?
Sample app http://dl.dropbox.com/u/6589941/icefilms_resolver/plugin.video.t0mm0.icefilms2.zip

nice start!

i think it would be simpler and neater if you used the common classes though (it handles cookies automatically for example). needs proper error handling too but that is easy enough.

i guess we should make a 2shared resolver plugin too...

please be aware that i am thinking of changing the UrlResolver interface (see a couple of post back and the videoid branch on github)

thanks,

t0mm0


- t0mm0 - 2011-09-17

hi all,

just pushed another update to the videoid branch on github. i updated letmewatchthis to use the new stuff and that showed up some bugs that i fixed and includes an updated version of choose_sources() which uses a list of HostedMediaFile objects instead of the old dict which means it is now sortable (i think i have covered everything you asked for now eldorado?)

i think i am still liking it so far so i'm going to port all the plugins and update the docs - if anyone has any objections or ideas now is the time to mention them Wink

hopefully i can then merge it back into master asap and then get a release out as more people are starting to use it we really need something stable-ish now.

as usual, please shout if i am doing something silly Wink

t0mm0


- DragonWin - 2011-09-17

Hey t0mm0,

Just wondering how the favorite stuff will be merged into master if the videoid is merged in before favorites?

As you know I'm still a n00b to Git, so not sure how this will affect it.


- t0mm0 - 2011-09-17

hi dragonwin,
DragonWin Wrote:Hey t0mm0,

Just wondering how the favorite stuff will be merged into master if the videoid is merged in before favorites?

As you know I'm still a n00b to Git, so not sure how this will affect it.

shouldn't be a problem, if there are any conflicts git will flag them up and i can merge manually. i think they probably don't overlap much if at all anyway.

t0mm0


- k_zeon - 2011-09-17

Hi t0mm0.
just tried the new version and

addon.add_video_item({'url':'http://www.megavideo.com/?v=LYWNYM1J'},
{'title': 'megavideo'})

fails . cannot resolve url

what else is required