2011-09-14, 16:25
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:
or 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:
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:
get_host_and_id() does the exact opposite - putlocker implementation follows:
valid_url() also has to be updated to check for either valid url or host:
(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
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')
Code:
f = urlresolver.HostedMediaFile(host='putlocker.com', media_id='DFE7599AE064911A')
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)
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