Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore website episode titles when meta data is disabled #80

Open
bstrdsmkr opened this issue Jun 25, 2013 · 10 comments
Open

Restore website episode titles when meta data is disabled #80

bstrdsmkr opened this issue Jun 25, 2013 · 10 comments

Comments

@bstrdsmkr
Copy link
Owner

No description provided.

@pishash
Copy link

pishash commented Aug 16, 2014

Its a bug in build_listitems(), change the disp_title = '....'
Then it should work.

else: # Metadata off
if video_type == 'episode':
disp_title = '%sx%s %s' % (season, episode, title)
listitem = xbmcgui.ListItem(disp_title, iconImage=img,
thumbnailImage=img)

There is also a bug with META ON:

Change meta['title'] to meta['TVShowTitle']

Greetz from Germany

@pishash
Copy link

pishash commented Aug 16, 2014

or easier: add this meta['title'] = meta['TVShowTitle']

if META_ON:
if video_type == 'episode':
meta = metaget.get_episode_meta(title, imdbnum, season, episode)
meta['TVShowTitle'] = title
meta['title'] = meta['TVShowTitle']

Then you don't need to change the rest ;)

@tknorris
Copy link
Contributor

I'll take a look at it today. I'm messing with this code today anyway.

@tknorris
Copy link
Contributor

This bug is about episode titles not showing in the episode view when metadata is turned off.

What you've suggested won't fix that. In the first suggestion, "title" is the title of the show, not the episode. In the 2nd suggestion, that's code is only executed when metadata is on, which makes it unrelated to this issue.

The goal here woudl be to parse out the episode titles that are in the season fragment and pass them into build_listitem so that they can be used when metadata is off. The problem with simply passing the episode title in as "title" though breaks when metadata is turned on.

In other words, this is a more complex bug that it seems at first. ;-)

@pishash
Copy link

pishash commented Aug 16, 2014

Please have a look into the code: Method build_listitems() (837) is called in create_item() (798) which is called in TVShowEpisodeList() (1085)
I tested this on a raspberry and a macos x with xbmc and it is working.

If the variable META_ON is true, it is getting his value into the list meta['TVShowTitle'] but if the listitem is build it is sending it to meta['title'](check 944) which is empty. I assume in previous revisions it was saved in meta['title'].

If META_ON is not true, the variable disp_title is getting only season and episode (check line 952).

@tknorris
Copy link
Contributor

I already checked the code. I agree that disp_title is only getting season and episode when metadata is off. That's only part of the problem though. The other part of the problem is the EPISODE title is not currently available in build_listitem when presenting the episode view. The TV Show Title is available and is in the "title" variable, which doesn't help.

@tknorris
Copy link
Contributor

Just to appease you that I really did look at this. Here is an example of what the episode view looks like when the change you suggested is made:
screenshot from 2014-08-16 17 38 04

Notice that title of each episode is the same and that it's the title of the TV Show not the episode...

@pishash
Copy link

pishash commented Aug 17, 2014

replace the build_items() method with this:

def build_listitem(video_type, title, year, img, resurl, imdbnum='', season='', episode='',extra_cms=None, subs=None):
if not subs: subs = []
if not extra_cms: extra_cms = []
menu_items = add_contextsearchmenu(title, section, resurl)
menu_items = menu_items + extra_cms

if video_type != 'episode' and 'Delete Favorite' not in [item[0] for item in menu_items]:
    queries = {'mode': 'SaveFav', 'section': section, 'title': title, 'url': resurl, 'year': year}
    runstring = 'RunPlugin(%s)' % _1CH.build_plugin_url(queries)
    menu_items.append(('Add to Favorites', runstring), )

queries = {'mode': 'add_to_library', 'video_type': video_type, 'title': title, 'img': img, 'year': year,
           'url': resurl}
runstring = 'RunPlugin(%s)' % _1CH.build_plugin_url(queries)
menu_items.append(('Add to Library', runstring), )
if video_type in ('tv', 'tvshow', 'episode'):
    queries = {'mode': 'add_subscription', 'video_type': video_type, 'url': resurl, 'title': title,
               'img': img, 'year': year}
    runstring = 'RunPlugin(%s)' % _1CH.build_plugin_url(queries)
    menu_items.append(('Subscribe', runstring), )
else:
    plugin_str = 'plugin://plugin.video.couchpotato_manager'
    plugin_str += '/movies/add?title=%s' % title
    runstring = 'XBMC.RunPlugin(%s)' % plugin_str
    menu_items.append(('Add to CouchPotato', runstring), )

if META_ON:
    if video_type == 'episode':
        meta = __metaget__.get_episode_meta(title, imdbnum, season, episode)
        meta['TVShowTitle'] = title
        meta['title'] = meta['TVShowTitle']

    else:
        meta = create_meta(video_type, title, year, img)

    if 'cover_url' in meta:
        img = meta['cover_url']

    menu_items.append(('Show Information', 'XBMC.Action(Info)'), )

    queries = {'mode': 'refresh_meta', 'video_type': video_type, 'title': meta['title'], 'imdb': meta['imdb_id'],
               'alt_id': 'imdbnum', 'year': year}
    runstring = _1CH.build_plugin_url(queries)
    runstring = 'RunPlugin(%s)' % runstring
    menu_items.append(('Refresh Metadata', runstring,))
    if 'trailer_url' in meta:
        try:
            url = meta['trailer_url']
            url = url.encode('base-64').strip()
            runstring = 'RunPlugin(%s)' % _1CH.build_plugin_url({'mode': 'PlayTrailer', 'url': url})
            menu_items.append(('Watch Trailer', runstring,))
        except: pass

    if meta['overlay'] == 6:
        label = 'Mark as watched'
        new_status = 7
    else:
        label = 'Mark as unwatched'
        new_status = 6

    queries = {'mode': 'ChangeWatched', 'title': title, 'imdbnum': meta['imdb_id'], 'video_type': video_type, 'year': year, 'watched': new_status}
    if video_type in ('tv', 'tvshow', 'episode'):
        queries['season'] = season
        queries['episode'] = episode
    runstring = 'RunPlugin(%s)' % _1CH.build_plugin_url(queries)
    menu_items.append((label, runstring,))

    fanart = ''
    if FANART_ON:
        try:
            fanart = meta['backdrop_url']
        except:
            fanart = ''

    if video_type == 'tvshow':
        if resurl in subs:
            meta['title'] = utils.format_label_sub(meta)
        else:
            meta['title'] = utils.format_label_tvshow(meta)
    elif video_type == 'episode':
        meta['title'] = utils.format_tvshow_episode(meta)
    else:
        meta['title'] = utils.format_label_movie(meta)

    listitem = xbmcgui.ListItem(meta['title'], iconImage=img,
                                thumbnailImage=img)
    listitem.setInfo('video', meta)
    listitem.setProperty('fanart_image', fanart)
    listitem.setProperty('imdb', meta['imdb_id'])
    listitem.setProperty('img', img)
    listitem.addContextMenuItems(menu_items, replaceItems=True)
else:  # Metadata off
    if video_type == 'episode':
        disp_title = '%sx%s %s' % (season, episode, title)
        listitem = xbmcgui.ListItem(disp_title, iconImage=img,
                                    thumbnailImage=img)
    else:
        if year:
            disp_title = '%s (%s)' % (title, year)
        else:
            disp_title = title
        listitem = xbmcgui.ListItem(disp_title, iconImage=img,
                                    thumbnailImage=img)
        listitem.addContextMenuItems(menu_items, replaceItems=True)

# Hack resumetime & totaltime to prevent XBMC from popping up a resume dialog if a native bookmark is set. UGH! 
listitem.setProperty('resumetime',str(0))
listitem.setProperty('totaltime',str(1))
return listitem

And I forgot to mention I did changed also in the method TVShowEpisodeList()

    create_item(section_params, title, year, '', epurl, imdbnum, season, epnum)

to

    create_item(section_params, eptitle, year, img, epurl, imdbnum, season, epnum)

@pishash
Copy link

pishash commented Aug 17, 2014

image

@tknorris
Copy link
Contributor

That breaks when metadata is turned on. get_episode_meta expects "title" to be the show title, not the epsiode title. The reason your test cases have probably worked is metahandlers only uses the show title when imdbid is blank.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants