Kodi Community Forum

Full Version: script.module.urlresolver development
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Eldorado Wrote:Very good so far! The new HostedMediaFile and the functionality around it work well, and I like the changes to choose_source()
cool, seems like it was the right move, sorry its taken so long to sort out!
Eldorado Wrote:Found an issue with filter_urls()

I'm assuming it can also be used to filter a list of hosts, as in not a url but simply a host name?

Code:
23:00:30 T:6548   ERROR: Error Type: <type 'exceptions.TypeError'>
23:00:30 T:6548   ERROR: Error Contents: valid_url() takes exactly 3 arguments (2 given)
23:00:30 T:6548   ERROR: Traceback (most recent call last):
                                              File "C:\Users\M33282\AppData\Roaming\XBMC\addons\plugin.video.quicksilverscreen\default.py", line 78, in <module>
                                                test = urlresolver.filter_urls(host)
                                              File "C:\Users\M33282\AppData\Roaming\XBMC\addons\script.module.urlresolver\lib\urlresolver\__init__.py", line 89, in filter_urls
                                                imp = find_resolver(url)
                                              File "C:\Users\M33282\AppData\Roaming\XBMC\addons\script.module.urlresolver\lib\urlresolver\__init__.py", line 137, in find_resolver
                                                if imp.valid_url(web_url):
                                            TypeError: valid_url() takes exactly 3 arguments (2 given)
23:00:30 T:6548    INFO: -->End of Python script error report<--

I've updated my addons in the separate branch, all working well so far!

yeah i still haven't done these other urlresolver.XXXX() functions yet. i don't even think this one will be needed as you could use the new urlresolver.filter_source_list() which works with HostedMediaFiles. anyway i am working on this stuff today....

by the way, are you planning on using urlresolver for livetvcafe? i was planning on doing that eventually and the seeon plugin is already written - seems like a good candidate!

t0mm0
looking at https://github.com/t0mm0/xbmc-urlresolve..._init__.py

i think not much of this is needed any more. i propose to get rid of:

resolve() - (you can now use the resolve() method on a HostedMediaFile object)
filter_urls()
filter_dict() - both of these are replaced by filter_source_list()
find_resolver() - was only really used by the other functions, equivalents are available in HostedMediaFile

this leaves only choose_source(), filter_source_list(), and display_settings() in the public API and _update_settings_xml() for internal use.

can anyone see a problem with that?

t0mm0
t0mm0 Wrote:cool, seems like it was the right move, sorry its taken so long to sort out!


yeah i still haven't done these other urlresolver.XXXX() functions yet. i don't even think this one will be needed as you could use the new urlresolver.filter_source_list() which works with HostedMediaFiles. anyway i am working on this stuff today....

Is filter_source_list() currently working?

I tried deleting the videoweed plugin, then passed in a list containing it and was passed back the same list:

Code:
[u'Vidxden', u'Vidxden', u'Vidxden', u'Vidxden', u'Novamov', u'Putlocker', u'Sockshare', u'Movshare', u'Videoweed']

I have a scenario with quicksilverscreen.im where I'm not sure how to filter my list given what we have..

Basically I get a list of source names and a link to a page with the video, I store this in a list (called a tuple?) - [('putlocker', 'http://....'), ('videobb', 'http://....')]

Is there a way to filter this list?

Perhaps keeping find_resolver() around would be useful in this situation? Basically just need to check if a resolver exists based on the host name... or did I miss being able to do this with HostedMediaFile ?


t0mm0 Wrote:by the way, are you planning on using urlresolver for livetvcafe? i was planning on doing that eventually and the seeon plugin is already written - seems like a good candidate!

t0mm0

I was, haven't gotten too far into it beyond directories for the main sections and listing out the popular/recently added channels from their rss feeds.. I have a couple other small bits figured out on how to grab channel lists

Did you want a go at it? A number of the streams are seeon.tv, but have noticed a handful that seem to be silverlight

Maybe I should direct my attention to getting metautils up and running instead Smile
Eldorado Wrote:Is filter_source_list() currently working?

I tried deleting the videoweed plugin, then passed in a list containing it and was passed back the same list:

Code:
[u'Vidxden', u'Vidxden', u'Vidxden', u'Vidxden', u'Novamov', u'Putlocker', u'Sockshare', u'Movshare', u'Videoweed']
yes filter_source_list() does work, but it is for filtering lists of HostedMediaFiles not strings. (i really need to update the docs properly....)
Eldorado Wrote:I have a scenario with quicksilverscreen.im where I'm not sure how to filter my list given what we have..

Basically I get a list of source names and a link to a page with the video, I store this in a list (called a tuple?) - [('putlocker', 'http://....'), ('videobb', 'http://....')]

Is there a way to filter this list?
as it stands, not without making the things you want to filter into HostedMediaLists. but maybe there should be a function that filters strings again?

Eldorado Wrote:Perhaps keeping find_resolver() around would be useful in this situation? Basically just need to check if a resolver exists based on the host name... or did I miss being able to do this with HostedMediaFile ?
you can do it with HostedMediaFile but you have to include a fake media_id. i think i will reinstate filter_urls() as that might be useful.

here is how to filter that list of tuples with what is currently available using a nice bit of list comprehension:
Code:
hosts = [('putlocker', 'http://blah1'), ('noresolverforthis', 'http://blah2'),
         ('videobb', 'http://blah3')]
        
hosts = [host for host in hosts
            if urlresolver.HostedMediaFile(host=host[0], media_id='XXX')]

#hosts is now:
#[('putlocker', 'http://blah1'), ('videobb', 'http://blah3')]
it's actually pretty neat!

Eldorado Wrote:I was, haven't gotten too far into it beyond directories for the main sections and listing out the popular/recently added channels from their rss feeds.. I have a couple other small bits figured out on how to grab channel lists

Did you want a go at it? A number of the streams are seeon.tv, but have noticed a handful that seem to be silverlight

Maybe I should direct my attention to getting metautils up and running instead Smile
i have plenty of other stuff to do so by all means carry on Wink

thanks,

t0mm0.
Question for the common library

I'm adding a number of infolabels in my metautils testing, and I've run into a problem with 2 items: rating and overlay

It looks like you are expecting to only have strings passed in for infolabel values, but this doesn't seem to work with ratings and overlay

If I pass in both as string values they don't appear anywhere in the movie info screen, if I pass them in as they are, float and numeric, I get the following error:

Code:
12:01:56 T:1812   ERROR: Error Contents: expected string or buffer
12:01:56 T:1812   ERROR: Traceback (most recent call last):
                                              File "C:\Users\M33282\AppData\Roaming\XBMC\addons\plugin.video.projectfreetv\default.py", line 202, in <module>
                                                GetMovieList(url)
                                              File "C:\Users\M33282\AppData\Roaming\XBMC\addons\plugin.video.projectfreetv\default.py", line 91, in GetMovieList
                                                addon.add_video_item({'url': newUrl, 'section': 'movies'}, infoLabels, total_items=len(match), img=infoLabels['thumb'], fanart=infoLabels['fanart'])
                                              File "C:\Users\M33282\AppData\Roaming\XBMC\addons\script.module.t0mm0.common\lib\t0mm0\common\addon.py", line 545, in add_video_item
                                                playlist, item_type='video')
                                              File "C:\Users\M33282\AppData\Roaming\XBMC\addons\script.module.t0mm0.common\lib\t0mm0\common\addon.py", line 515, in add_item
                                                infolabels = self.unescape_dict(infolabels)
                                              File "C:\Users\M33282\AppData\Roaming\XBMC\addons\script.module.t0mm0.common\lib\t0mm0\common\addon.py", line 672, in unescape_dict
                                                out[key] = self.unescape(value)
                                              File "C:\Users\M33282\AppData\Roaming\XBMC\addons\script.module.t0mm0.common\lib\t0mm0\common\addon.py", line 646, in unescape
                                                text = self.decode(text)
                                              File "C:\Users\M33282\AppData\Roaming\XBMC\addons\script.module.t0mm0.common\lib\t0mm0\common\addon.py", line 631, in decode
                                                return re.sub("&#(\d+)(;|(?=\s))", self._decode_callback, data).strip()
                                              File "C:\Program Files (x86)\XBMC\system\python\Lib\re.py", line 151, in sub
                                                return _compile(pattern, 0).sub(repl, string, count)
                                            TypeError: expected string or buffer
12:01:56 T:1812    INFO: -->End of Python script error report<--

Referencing Icefilms, he passes them in as so and display properly:
Code:
infoLabels['rating'] = float(meta['rating'])
             infoLabels['overlay'] = meta['watched'] # watched 7, unwatched 6
Also...

Would be nice to be able to add some extra metadata to directories, currently not possible with add_directory()

This is handy for TV Shows where the show is a high level folder, quite a bit of metadata can be scraped for the show itself, then seasons and episodes as sub folders below it
I updated the icefilms resolver on http://dl.dropbox.com/u/6589941/icefilms...lms.py.txt to videoid code base. I noticed some httplib dependent libraries urllib etc have poor perf on atv2 http://forum.xbmc.org/showthread.php?tid=110698. Would you consider refactoring your import calls till only when they are required?
hi,

sorry for the lack of progress recently, things are a bit on the busy side for me Sad rest assured i have not given up Wink

Eldorado Wrote:Question for the common library

I'm adding a number of infolabels in my metautils testing, and I've run into a problem with 2 items: rating and overlay

It looks like you are expecting to only have strings passed in for infolabel values, but this doesn't seem to work with ratings and overlay
yeah, my mistake - easy enough to fix - i reckon probably just catching TypeErrors in unescape() and ignoring them is probably the best way to go? testing for some klind of 'stringy' type seems to be the wrong way to go in pyhthon i think?
Eldorado Wrote:Also...

Would be nice to be able to add some extra metadata to directories, currently not possible with add_directory()

This is handy for TV Shows where the show is a high level folder, quite a bit of metadata can be scraped for the show itself, then seasons and episodes as sub folders below it

can you point to how this is done - is it through infolabels again?

slyi Wrote:I updated the icefilms resolver on http://dl.dropbox.com/u/6589941/icefilms...lms.py.txt to videoid code base.
cool i'll try and take a look over the weekend.
slyi Wrote:I noticed some httplib dependent libraries urllib etc have poor perf on atv2 http://forum.xbmc.org/showthread.php?tid=110698. Would you consider refactoring your import calls till only when they are required?

i guess that is probably the best way around it (although i assume that there aren't many times that a urlresolver gets called without using network access?)

thanks,

t0mm0
t0mm0 Wrote:hi,

sorry for the lack of progress recently, things are a bit on the busy side for me Sad rest assured i have not given up Wink


yeah, my mistake - easy enough to fix - i reckon probably just catching TypeErrors in unescape() and ignoring them is probably the best way to go? testing for some klind of 'stringy' type seems to be the wrong way to go in pyhthon i think?

I haven't looked to closely at your code, but sounds reasonable.. I've only worked with 2 infolabels so far that are non-string, ratings (float) and overlay (integer)

I would like to do cast but am unsure of the format so far, the description says it's a concatenated string, though anything I've passed into it so far has not worked..

t0mm0 Wrote:can you point to how this is done - is it through infolabels again?

I'm using Icefilms as my main reference when working with the meta data, when defining the listitem he sets the type='Video' and applies the infolabels

Code:
liz.setInfo(type="Video", infoLabels=infoLabels)
..
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True)

I'm assuming the type='Video' is what enables the infolabels (?)

In your common, maybe all we need to do is add a new switch to either add_item() or add_video_item()? Or Both?

Code:
def add_item(self, play, infolabels, img='', fanart='', resolved=False,
            total_items=0, playlist=False, item_type='video',[b] is_folder=False[/b]):
...
..
    [b]if not is_folder:[/b]
        if not resolved:
            play['play'] = 'True'
            play = self.build_plugin_url(play)
        else:
            play = play['url']
..
...
xbmcplugin.addDirectoryItem(self.handle, play, listitem,
                         isFolder=[b]is_folder[/b], totalItems=total_items)

This way I could specify on my own whether I'm adding a playable item or just a folder with the same attributes...
The ATV2 issue relates to python interpreter speed on heavy libraries like urllib2. I come from a web world where page load time is #1 priority. If your net library had simple http get function using only a basic socket like on http://forum.xbmc.org/showthread.php?tid=110698 it would be very responsive for most actions until your require a advanced http get or post request.

eg:
  1. Load your plugin & display categories (no net request & sub second load time)
  2. Pick a category eg: TV A-Z (no net request & sub second load time)
  3. Pick letter eg: X (simple socket get request & sub second load time)
  4. Pick Show eg: X-Files (simple socket get request & sub second load time)
  5. Pick Season eg: Season 1 (no net request & sub second load time)
  6. Pick Episode eg: episode 1 (advanced net request and resolve with the 4 second load time)
  7. Pick Stream source eg: Stream 1 (advanced net request and resolve with the 4 second load time)

t0mm0 Wrote:i guess that is probably the best way around it (although i assume that there aren't many times that a urlresolver gets called without using network access?)
hi slyi!
slyi Wrote:The ATV2 issue relates to python interpreter speed on heavy libraries like urllib2. I come from a web world where page load time is #1 priority.
i do too, but none of my devices have this issue so i have not noticed a problem until you brought it up (looked at getting appletv boxes but they seem too underpowered for this kind of thing to me Wink).
slyi Wrote:If your net library had simple http get function using only a basic socket like on http://forum.xbmc.org/showthread.php?tid=110698 it would be very responsive for most actions until your require a advanced http get or post request.
sounds a bit annoying to me, we basically end up rewriting urllib2? i can't see how you determine when you want a 'simple' or 'advanced' call (or what the difference is). we would have 2 APIs and push the choice back down to the addon dev? i'd rather someone worked out why the fault exists in the first place than add all that complication....

slyi Wrote:eg:
  1. Load your plugin & display categories (no net request & sub second load time)
  2. Pick a category eg: TV A-Z (no net request & sub second load time)
  3. Pick letter eg: X (simple socket get request & sub second load time)
  4. Pick Show eg: X-Files (simple socket get request & sub second load time)
  5. Pick Season eg: Season 1 (no net request & sub second load time)
  6. Pick Episode eg: episode 1 (advanced net request and resolve with the 4 second load time)
  7. Pick Stream source eg: Stream 1 (advanced net request and resolve with the 4 second load time)

where a urlresolver call (and therefore a net request) is not needed, just don't import urlresolver (which therefore would not import urllib2 or httplib) - i thought that was what you were suggesting originally?

of course if you want to rewrite urllib2 and make it available we could use that instead Wink but it seems like a lot of effort and lots of added code to maintain to save a few seconds on a particular device...

i still think it might be easier to track down the actual problem (but then i guess i would say that as it wouldn't be me doing it Wink).

t0mm0
cool module, I've actually started to write something similar, but much more simple :-) on github too. Do you plan to push it into official repo? Otherwise it is not usable for my addons and the only thing I can do is copy your resolvers that I do not have yet.
Libor
hi!
lzoubek Wrote:cool module, I've actually started to write something similar, but much more simple :-) on github too. Do you plan to push it into official repo? Otherwise it is not usable for my addons and the only thing I can do is copy your resolvers that I do not have yet.
Libor

nice! urlresolver is more complicated as there were more required features. we'll have to 'borrow' the resolvers you've done that we haven't too Cool.

yes i plan to get it into the official repo, the original idea of this stuff was to make it so that we didn't all have to keep rewriting the same code Wink if a site changes, it will be much easier to update it once in urlresolver than for everyone to fix their own addons individually.

that is partly why i haven't released it yet (i wanted to make sure the API was pretty stable before 'officially' releasing it so that we didn't end up supporting initial mistakes!). i think we are nearly there with the videoid branch, there are some small changes still to come detailed in this thread (and please suggest anything you think will make it better!), but the biggest thing to do before merging back to master is updating all the docs (it takes ages but the point of this was to make it easy for anyone to use and i think docs are the key to that).

so yeah, it will be a couple of weeks before a stable version is released as i have a lot on at the moment and can't devote much time to this now, but it will get there 'soon'. (and in a few weeks i will have loads of time to play with it!)

t0mm0
Hi t0mm0

just been playing around with eldorados new metautils and he said that at present i cannot add infolabels to directories but only on addvideoitem

just wondered if this is something that will be implemented and if poss a timescale.

many thanks for all your hard work
k_zeon Wrote:Hi t0mm0

just been playing around with eldorados new metautils and he said that at present i cannot add infolabels to directories but only on addvideoitem

just wondered if this is something that will be implemented and if poss a timescale.

many thanks for all your hard work

i've already discussed in eldorados thread that this will be fixed. i'm afraid i'm really busy at the moment and might not get to do much for a couple of weeks (see the post above yours)

thanks,

t0mm0
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