script.module.metautils dev

  Thread Rating:
  • 2 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
k_zeon Offline
Senior Member
Posts: 217
Joined: Aug 2011
Reputation: 0
Post: #106
Eldorado Wrote:What happens when you pass in those values? Do you see 0's in xbmc?

I would hope it would just not display them.. sort of like a i' value > 0' then display type of check

Hey Eldorado

No i keep getting script errors after loading so many menu Dirs, i think on Rating or Duration.
when i take out the code for them and dont add them to dir it works.
Nothing is getting displayed when using infolabels['rating']=float(0) etc but this must be where it errors out


Here is my def to load Directories.
Code:
def add_Metadirectory(self, queries, infolabels,title='', img='', fanart='', resolved=False, total_items=0,  item_type='video'):

    
         infolabels = self.unescape_dict(infolabels)
        
         url = self.build_plugin_url(queries)
        
         listitem = xbmcgui.ListItem(title, iconImage=img, thumbnailImage=img)
         self.log_debug(u'adding movie: %s - %s' % (infolabels['title'], infolabels['rating']))

         if infolabels['plot'] is None:
            infolabels['plot']=''
         if infolabels['rating'] is None:
            infolabels['rating']=str('')
         if infolabels['genre'] is None:
            infolabels['genre']=''
         if infolabels['duration'] is None:
            infolabels['duration']=str('')  
         if infolabels['mpaa'] is None:
            infolabels['mpaa']=''
         if infolabels['trailer_url'] is None:
            infolabels['trailer_url']=''
         if infolabels['cast'] is None:
            infolabels['cast']=''
  
         listitem.setInfo('video', {'Title': title, 'Genre': infolabels['genre'], 'Plot': infolabels['plot'], 'Rating': float(infolabels['rating']),
                                    'Duration': infolabels['duration'],'Cast': infolabels['cast'],'Trailer': infolabels['trailer_url']})

         xbmcplugin.addDirectoryItem(self.handle, url, listitem, isFolder=True, totalItems=total_items)

and the calling line in my addon is:
addon.add_Metadirectory({'mode' : 'GetMovieSource', 'url' : url }, meta ,total_items=len(match),title=CleanHTML(name) + ' (' + sYear + ')' , img=meta['cover_url'])

Just Pushed a New Git for you to test.

if i do this listitem.setInfo('video', {'Title': title, 'Genre': infolabels['genre'], 'Plot': infolabels['plot'],'Cast': infolabels['cast'],'Trailer': infolabels['trailer_url']})
then it works and the menu's get load and i can see the thumbnail, i can get plot etc.
(This post was last modified: 2011-10-22 18:30 by k_zeon.)
find quote
k_zeon Offline
Senior Member
Posts: 217
Joined: Aug 2011
Reputation: 0
Post: #107
Hey Eldorado. any luck with why some of the infolabels are failing.

Also how to play the Youtube Trailers as they all do not work at present
The animated circle shows then just disappears.
(This post was last modified: 2011-10-22 22:08 by k_zeon.)
find quote
slyi Offline
Junior Member
Posts: 40
Joined: Sep 2011
Reputation: 0
Post: #108
k_zeon Wrote:Also how to play the Youtube Trailers as they all do not work at present
The animated circle shows then just disappears.

I find this works ok
PHP Code:
infoLabels['trailer'] = urlresolver.HostedMediaFile(url=meta['trailer_url']).resolve() 
find quote
slyi Offline
Junior Member
Posts: 40
Joined: Sep 2011
Reputation: 0
Post: #109
Eldorado Wrote:Check the icefilms dev thread in this forum, one of the last posts I gave a link to a forked version where I merged the master branch with stable, master is the unfinished branch with many new features

Not sure about merging with t0mm0's lib, there's a lot of cleanup that would need to be done in the icefilms code to get to that point

Ok i can do that, it will take me a few days to complete a patch but have you considered creating a urlresolver branch aswell for icesfilms most the major functionality are working now eg: ice resolver sample on http://dl.dropbox.com/u/6589941/icefilms...lms.py.txt, it could be a future point release 1.1.0. Anarchintosh's original code works well but it does need refactoring around the new script modules.

BTW: Im seeing
PHP Code:
Error attempting to insert into cache tablecolumns imdb_idtvdb_idepisode_idtitleseasonepisode are not unique 
for "my name is earl" episodes, have you encountered this before?
find quote
k_zeon Offline
Senior Member
Posts: 217
Joined: Aug 2011
Reputation: 0
Post: #110
slyi Wrote:I find this works ok
PHP Code:
infoLabels['trailer'] = urlresolver.HostedMediaFile(url=meta['trailer_url']).resolve() 

Hi Slyi

I use Eldorado's Metahandler module to get the meta data.
in this module is meta['trailer_url'] = md.get('trailer', '')

if i try:
infoLabels['trailer'] = urlresolver.HostedMediaFile(url=md.get('trailer', '')).resolve() << this should work but does not
tried adding this to metahandler. did not work. but got circle animation.


I tried this in my addon before adding to the Dir. Did not work. script error
tried adding to t0mm0's module , but script error.

whare should i try to put it.

tks
(This post was last modified: 2011-10-23 15:29 by k_zeon.)
find quote
slyi Offline
Junior Member
Posts: 40
Joined: Sep 2011
Reputation: 0
Post: #111
k_zeon Wrote:Hi Slyi

I use Eldorado's Metahandler module to get the meta data.
in this module is meta['trailer_url'] = md.get('trailer', '')

if i try:
infoLabels['trailer'] = urlresolver.HostedMediaFile(url=md.get('trailer', '')).resolve() << this should work but does not
tried adding this to metahandler. did not work. but got circle animation.


I tried this in my addon before adding to the Dir. Did not work. script error
tried adding to t0mm0's module , but script error.

whare should i try to put it.

tks

I just put it in my addon piece and it seems to work fine for the A-team movie in my dropbox sample above, i just add movies support (not all movies have imdbs so im going to need to add name search later)
find quote
Eldorado Offline
Fan
Posts: 519
Joined: May 2009
Reputation: 14
Post: #112
slyi Wrote:Ok i can do that, it will take me a few days to complete a patch but have you considered creating a urlresolver branch aswell for icesfilms most the major functionality are working now eg: ice resolver sample on http://dl.dropbox.com/u/6589941/icefilms...lms.py.txt, it could be a future point release 1.1.0. Anarchintosh's original code works well but it does need refactoring around the new script modules.

BTW: Im seeing
PHP Code:
Error attempting to insert into cache tablecolumns imdb_idtvdb_idepisode_idtitleseasonepisode are not unique 
for "my name is earl" episodes, have you encountered this before?

It would be nice to get to the point of using t0mm0's libraries with Icefilms, but I can only assume there will need to be major re-structuring of the code to get there.. the 1.1.0 release will likely just focus on the already included new features, then if anyone wants to take the challenge after that to rework it with t0mm0's libs

Can you post up the full debug log where you are getting that error? Basicalliy means it is trying to insert an exact duplicate row into the episode_meta table, and for some reason it did not find and delete the original one before trying to add the new
find quote
Eldorado Offline
Fan
Posts: 519
Joined: May 2009
Reputation: 14
Post: #113
k_zeon Wrote:Hi Slyi

I use Eldorado's Metahandler module to get the meta data.
in this module is meta['trailer_url'] = md.get('trailer', '')

if i try:
infoLabels['trailer'] = urlresolver.HostedMediaFile(url=md.get('trailer', '')).resolve() << this should work but does not
tried adding this to metahandler. did not work. but got circle animation.


I tried this in my addon before adding to the Dir. Did not work. script error
tried adding to t0mm0's module , but script error.

whare should i try to put it.

tks

Where are you getting md.get('trailer', '') ? That looks like something I've done inside the metahandlers class, it's not valid outside of it

I believe you had the correct piece of code in your addon earlier to make them play:

Code:
try:
        trailer_id = re.match('^[^v]+v=(.{11}).*', meta['trailer_url']).group(1)
        infoLabels['trailer'] = "plugin://plugin.video.youtube/?action=play_video&videoid=%s" % trailer_id
    except:
        infoLabels['trailer'] = ''

This I snagged from the Icefilms code, I haven't given it much thought so there's probably other ways of doing it.. but it simply grabs the video id and passes it into the Youtube addon to play, and as slyi said you can also use the urlresolver on it which might be easier
(This post was last modified: 2011-10-24 18:39 by Eldorado.)
find quote
Eldorado Offline
Fan
Posts: 519
Joined: May 2009
Reputation: 14
Post: #114
Just pushed in some more updates:

- added search_movies() method to metahanlders, this is intended to be used for single movie refreshing, you pass in a *clean* name only, it will search TMDB based on that name and return an array of dicts of possible matches

Info passed back:
- TMDB ID
- IMDB ID
- Name
- Year

You can display this info to the user in a dialog box, allow them to select one from the list and then re-call get_meta() passing in the imdb id/tmdb id of what was selected

- Due to this search feature I had to modify get_meta() slightly, it now accepts passing in a tmdb id (as you could get a search result that doesn't have an imdb id), so I re-ordered the variables passed in

I'll update the examples in the first post, basics:

get_meta('movie', 'The Hangover', imdb_id='tt1119646')
or
get_meta('movie', '40 Year Old Virgin', year='2005')
or
get_meta('movie','Horrible Bosses', tmdb_id='51540')
or
get_meta('tvshow','The Simpsons')

- A few more code cleanups here and there.. currently my datetime conversion stuff is having issues, at least for me running pre-eden nightlies.. so you might see some errors relating to that in the logs

Otherwise aside from some bug fixes that might pop up, I'm pretty much finished messing with metahandlers and moving on to metacontainers which is the class that will do the installing of meta data packs

I can almost see the light at the end of the tunnel Smile
find quote
k_zeon Offline
Senior Member
Posts: 217
Joined: Aug 2011
Reputation: 0
Post: #115
Eldorado Wrote:Where are you getting md.get('trailer', '') ? That looks like something I've done inside the metahandlers class, it's not valid outside of it

I believe you had the correct piece of code in your addon earlier to make them play:

Code:
try:
        trailer_id = re.match('^[^v]+v=(.{11}).*', meta['trailer_url']).group(1)
        infoLabels['trailer'] = "plugin://plugin.video.youtube/?action=play_video&videoid=%s" % trailer_id
    except:
        infoLabels['trailer'] = ''

This I snagged from the Icefilms code, I haven't given it much thought so there's probably other ways of doing it.. but it simply grabs the video id and passes it into the Youtube addon to play, and as slyi said you can also use the urlresolver on it which might be easier

Hey Eldorado.
The code in ProjectfreeTV has following def

Code:
def create_infolabels(meta, name):
    infoLabels = {}
    infoLabels['title'] = name
    infoLabels['plot'] = str(meta['plot'])
    infoLabels['genre'] = str(meta['genres'])
    infoLabels['duration'] = str(meta['duration'])
    infoLabels['premiered'] = str(meta['premiered'])
    infoLabels['studio'] = meta['studios']
    infoLabels['mpaa'] = str(meta['mpaa'])
    infoLabels['code'] = str(meta['imdb_id'])
    #infoLabels['rating'] = str(meta['rating'])
    #infoLabels['overlay'] = str(meta['watched']) # watched 7, unwatched 6
    infoLabels['thumb'] = str(meta['cover_url'])
    if meta.has_key('backdrop_url'):
        infoLabels['fanart'] = str(meta['backdrop_url'])
    infoLabels['imdb_id'] = meta['imdb_id']
    
    try:
        trailer_id = re.match('^[^v]+v=(.{11}).*', meta['trailer_url']).group(1)
        infoLabels['trailer'] = "plugin://plugin.video.youtube/?action=play_video&videoid=%s" % trailer_id
    except:
        infoLabels['trailer'] = ''
    
    return infoLabels

But this def is no longer called.

ie.
Code:
def GetMovieList(url):

    html = net.http_GET(url).content
    match = re.compile('<td width="97%" class="mnlcategorylist"><a href="(.+?)"><b>(.+?) [(]*([0-9]{4})[)]*</b></a>(.+?)<').findall(html)

    metaget=metahandlers.MetaData()
    for link, movie, year, numlinks in match:
       if re.search("../",link) is not None:
          link = link.strip('\n').replace("../","")
          newUrl = MovieUrl + link
       else:
          newUrl = url + "/" + link
       meta = metaget.get_meta('', 'movie', movie, year)
       addon.add_video_item({'url': newUrl, 'section': 'movies'}, meta, total_items=len(match), img=meta['cover_url'], fanart=meta['backdrop_url'])

so below is not processed. where should the call to create_infolabels be placed.
Code:
try:
        trailer_id = re.match('^[^v]+v=(.{11}).*', meta['trailer_url']).group(1)
        infoLabels['trailer'] = "plugin://plugin.video.youtube/?action=play_video&videoid=%s" % trailer_id
    except:
        infoLabels['trailer'] = ''

Thanks for all your hard work. Really appreciate the time and effort you have put in....
find quote
k_zeon Offline
Senior Member
Posts: 217
Joined: Aug 2011
Reputation: 0
Post: #116
just run new version of Metahandler and get error

http://pastebin.com/CrLqgBSe

problem in metacontainers with the word self
find quote
Eldorado Offline
Fan
Posts: 519
Joined: May 2009
Reputation: 14
Post: #117
k_zeon Wrote:Hey Eldorado.
The code in ProjectfreeTV has following def

Code:
def create_infolabels(meta, name):
    infoLabels = {}
    infoLabels['title'] = name
    infoLabels['plot'] = str(meta['plot'])
    infoLabels['genre'] = str(meta['genres'])
    infoLabels['duration'] = str(meta['duration'])
    infoLabels['premiered'] = str(meta['premiered'])
    infoLabels['studio'] = meta['studios']
    infoLabels['mpaa'] = str(meta['mpaa'])
    infoLabels['code'] = str(meta['imdb_id'])
    #infoLabels['rating'] = str(meta['rating'])
    #infoLabels['overlay'] = str(meta['watched']) # watched 7, unwatched 6
    infoLabels['thumb'] = str(meta['cover_url'])
    if meta.has_key('backdrop_url'):
        infoLabels['fanart'] = str(meta['backdrop_url'])
    infoLabels['imdb_id'] = meta['imdb_id']
    
    try:
        trailer_id = re.match('^[^v]+v=(.{11}).*', meta['trailer_url']).group(1)
        infoLabels['trailer'] = "plugin://plugin.video.youtube/?action=play_video&videoid=%s" % trailer_id
    except:
        infoLabels['trailer'] = ''
    
    return infoLabels

But this def is no longer called.

ie.
Code:
def GetMovieList(url):

    html = net.http_GET(url).content
    match = re.compile('<td width="97%" class="mnlcategorylist"><a href="(.+?)"><b>(.+?) [(]*([0-9]{4})[)]*</b></a>(.+?)<').findall(html)

    metaget=metahandlers.MetaData()
    for link, movie, year, numlinks in match:
       if re.search("../",link) is not None:
          link = link.strip('\n').replace("../","")
          newUrl = MovieUrl + link
       else:
          newUrl = url + "/" + link
       meta = metaget.get_meta('', 'movie', movie, year)
       addon.add_video_item({'url': newUrl, 'section': 'movies'}, meta, total_items=len(match), img=meta['cover_url'], fanart=meta['backdrop_url'])

so below is not processed. where should the call to create_infolabels be placed.
Code:
try:
        trailer_id = re.match('^[^v]+v=(.{11}).*', meta['trailer_url']).group(1)
        infoLabels['trailer'] = "plugin://plugin.video.youtube/?action=play_video&videoid=%s" % trailer_id
    except:
        infoLabels['trailer'] = ''

Thanks for all your hard work. Really appreciate the time and effort you have put in....

Yeah, don't be looking too closely at project free tv since I'm not consistently updating it and testing specific things elsewhere.. it's a bit of a mess right now

Basically you will need to handle the meta data once it's returned to you slightly for the trailer

k_zeon Wrote:just run new version of Metahandler and get error

http://pastebin.com/CrLqgBSe

problem in metacontainers with the word self

Oops, copy/paste error.. got it and sent it up thanks! Probably not worthwhile importing this class yet until it actually does something
find quote
k_zeon Offline
Senior Member
Posts: 217
Joined: Aug 2011
Reputation: 0
Post: #118
Yes it seems to be working now. tks. Re: Projectfreetv its the only example i have to go by at the moment.

Is it possible that the below code can be added to the Metahandler module so we dont have to handle it. tks

Code:
try:
        trailer_id = re.match('^[^v]+v=(.{11}).*', meta['trailer_url']).group(1)
        infoLabels['trailer'] = "plugin://plugin.video.youtube/?action=play_video&videoid=%s" % trailer_id
    except:
        infoLabels['trailer'] = ''
(This post was last modified: 2011-10-24 22:51 by k_zeon.)
find quote
Eldorado Offline
Fan
Posts: 519
Joined: May 2009
Reputation: 14
Post: #119
k_zeon Wrote:Yes it seems to be working now. tks. Re: Projectfreetv its the only example i have to go by at the moment.

Is it possible that the below code can be added to the Metahandler module so we dont have to handle it. tks

Code:
try:
        trailer_id = re.match('^[^v]+v=(.{11}).*', meta['trailer_url']).group(1)
        infoLabels['trailer'] = "plugin://plugin.video.youtube/?action=play_video&videoid=%s" % trailer_id
    except:
        infoLabels['trailer'] = ''

I was considering it, but then thought it's probably best that I don't do that in case things such as the youtube addon changes, or you just would like to play it differently for whatever reason eg. with the urlresolver

I guess this is up for debate, generally I like to pass back unmolested data which may force you to take certain directions unless there is a specific reason for touching it, this could be a case where I do.. but I'm very 50/50 on it

Anyone want to chime in on the topic?
find quote
k_zeon Offline
Senior Member
Posts: 217
Joined: Aug 2011
Reputation: 0
Post: #120
Eldorado, How would you call the search feature to update a single Movie. If on Apple TV2 , would it be select movie then hold menu to popup context menu...

Eldorado Wrote:Just pushed in some more updates:

- added search_movies() method to metahanlders, this is intended to be used for single movie refreshing, you pass in a *clean* name only, it will search TMDB based on that name and return an array of dicts of possible matches

Info passed back:
- TMDB ID
- IMDB ID
- Name
- Year

You can display this info to the user in a dialog box, allow them to select one from the list and then re-call get_meta() passing in the imdb id/tmdb id of what was selected
find quote
Post Reply