Ejemplo n.º 1
0
def play_trailer(trailer_url,
                 thumb='',
                 trailer_file='',
                 playable=True,
                 meta=None):
    if meta is None: meta = {}
    path = kodi.get_setting('download_path')
    if path and trailer_file:
        local_file = local_utils.trailer_exists(path, trailer_file)
        if local_file:
            trailer_url = os.path.join(path, local_file)

    if trailer_url.startswith('http'):
        trailer_url = local_utils.resolve_trailer(trailer_url)
        trailer_url += '|User-Agent=%s' % (BROWSER_UA)

    listitem = xbmcgui.ListItem(path=trailer_url,
                                iconImage=thumb,
                                thumbnailImage=thumb)
    if meta:
        if 'streams' in meta: del meta['streams']
        listitem.setInfo('video', meta)
    try:
        listitem.setArt({'thumb': thumb})
    except:
        pass
    listitem.setPath(trailer_url)
    if playable:
        xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
    else:
        xbmc.Player().play(trailer_url, listitem=listitem)
def show_trailers(location, movie_id='', poster='', fanart=''):
    path = kodi.get_setting('download_path')
    for trailer in scraper.get_trailers(location, movie_id):
        trailer['fanart'] = fanart
        trailer['poster'] = poster
        stream_url = local_utils.get_best_stream(trailer['streams'], 'stream')
        download_url = local_utils.get_best_stream(trailer['streams'], 'download')
        label = trailer['title']
        if path:
            file_name = utils.create_legal_filename(trailer['title'], trailer.get('year', ''))
            if local_utils.trailer_exists(path, file_name):
                label += ' [I](%s)[/I]' % (i18n('downloaded'))
        else:
            file_name = ''
            
        liz = utils.make_list_item(label, trailer, local_utils.make_art(trailer))
        liz.setProperty('isPlayable', 'true')
        del trailer['streams']
        liz.setInfo('video', trailer)

        menu_items = []
        queries = {'mode': MODES.DOWNLOAD_TRAILER, 'trailer_url': download_url, 'title': trailer['title'], 'year': trailer.get('year', '')}
        runstring = 'RunPlugin(%s)' % (kodi.get_plugin_url(queries))
        menu_items.append((i18n('download_trailer'), runstring),)
        liz.addContextMenuItems(menu_items, replaceItems=False)
        
        queries = {'mode': MODES.PLAY_TRAILER, 'trailer_url': stream_url, 'thumb': trailer.get('thumb', ''), 'trailer_file': file_name}
        liz_url = kodi.get_plugin_url(queries)
        xbmcplugin.addDirectoryItem(int(sys.argv[1]), liz_url, liz, isFolder=False)
    kodi.set_view('movies', set_view=True)
    kodi.end_of_directory()
Ejemplo n.º 3
0
def show_trailers(location, movie_id='', poster='', fanart=''):
    path = kodi.get_setting('download_path')
    for trailer in scraper.get_trailers(location, movie_id):
        trailer['fanart'] = fanart
        trailer['poster'] = poster
        stream_url = local_utils.get_best_stream(trailer['streams'], 'stream')
        download_url = local_utils.get_best_stream(trailer['streams'],
                                                   'download')
        label = trailer['title']
        if path:
            file_name = utils.create_legal_filename(trailer['title'],
                                                    trailer.get('year', ''))
            if local_utils.trailer_exists(path, file_name):
                label += ' [I](%s)[/I]' % (i18n('downloaded'))
        else:
            file_name = ''

        liz = utils.make_list_item(label, trailer,
                                   local_utils.make_art(trailer))
        liz.setProperty('isPlayable', 'true')
        del trailer['streams']
        liz.setInfo('video', trailer)

        menu_items = []
        queries = {
            'mode': MODES.DOWNLOAD_TRAILER,
            'trailer_url': download_url,
            'title': trailer['title'],
            'year': trailer.get('year', '')
        }
        runstring = 'RunPlugin(%s)' % (kodi.get_plugin_url(queries))
        menu_items.append((i18n('download_trailer'), runstring), )
        liz.addContextMenuItems(menu_items, replaceItems=False)

        queries = {
            'mode': MODES.PLAY_TRAILER,
            'trailer_url': stream_url,
            'thumb': trailer.get('thumb', ''),
            'trailer_file': file_name
        }
        liz_url = kodi.get_plugin_url(queries)
        xbmcplugin.addDirectoryItem(int(sys.argv[1]),
                                    liz_url,
                                    liz,
                                    isFolder=False)
    kodi.set_view('movies', set_view=True)
    kodi.end_of_directory()
def play_trailer(trailer_url, thumb='', trailer_file='', playable=True, meta=None):
    if meta is None: meta = {}
    path = kodi.get_setting('download_path')
    if path and trailer_file:
        local_file = local_utils.trailer_exists(path, trailer_file)
        if local_file:
            trailer_url = os.path.join(path, local_file)

    if trailer_url.startswith('http'):
        trailer_url = local_utils.resolve_trailer(trailer_url)
        trailer_url += '|User-Agent=%s' % (BROWSER_UA)
        
    listitem = xbmcgui.ListItem(path=trailer_url, iconImage=thumb, thumbnailImage=thumb)
    if meta:
        if 'streams' in meta: del meta['streams']
        listitem.setInfo('video', meta)
    try: listitem.setArt({'thumb': thumb})
    except: pass
    listitem.setPath(trailer_url)
    if playable:
        xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
    else:
        xbmc.Player().play(trailer_url, listitem=listitem)