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 show_movies():
    try: limit = int(kodi.get_setting('limit'))
    except: limit = 0
    try: source = int(kodi.get_setting('source'))
    except: source = 0
    list_data = local_utils.make_list_dict()
    for movie in get_movies(source, limit):
        label = movie['title']
        key = movie['title'].upper()
        if key in list_data:
            if 'year' not in movie or not movie['year'] or not list_data[key] or int(movie['year']) in list_data[key]:
                label = '[COLOR green]%s[/COLOR]' % (label)
        
        liz = utils.make_list_item(label, movie, local_utils.make_art(movie))
        liz.setInfo('video', movie)
        
        menu_items = []
        queries = {'mode': MODES.PLAY_RECENT, 'movie_id': movie['movie_id'], 'location': movie['location'], 'thumb': movie.get('poster', '')}
        runstring = 'RunPlugin(%s)' % (kodi.get_plugin_url(queries))
        menu_items.append((i18n('play_most_recent'), runstring),)
        queries = {'mode': MODES.ADD_TRAKT, 'title': movie['title'], 'year': movie.get('year', '')}
        runstring = 'RunPlugin(%s)' % (kodi.get_plugin_url(queries))
        menu_items.append((i18n('add_to_trakt'), runstring),)
        runstring = 'RunPlugin(%s)' % (CP_ADD_URL % (movie['title']))
        menu_items.append((i18n('add_to_cp'), runstring),)
        liz.addContextMenuItems(menu_items, replaceItems=False)
        
        queries = {'mode': MODES.TRAILERS, 'movie_id': movie['movie_id'], 'location': movie['location'], 'poster': movie.get('poster', ''), 'fanart': movie.get('fanart', '')}
        liz_url = kodi.get_plugin_url(queries)
        xbmcplugin.addDirectoryItem(int(sys.argv[1]), liz_url, liz, isFolder=True)
    kodi.set_view('movies', set_sort=True)
    kodi.end_of_directory(cache_to_disc=False)
Example #3
0
def show_movies():
    try:
        limit = int(kodi.get_setting('limit'))
    except:
        limit = 0
    try:
        source = int(kodi.get_setting('source'))
    except:
        source = 0
    list_data = local_utils.make_list_dict()
    for movie in get_movies(source, limit):
        label = movie['title']
        key = movie['title'].upper()
        if key in list_data:
            if 'year' not in movie or not movie['year'] or not list_data[
                    key] or int(movie['year']) in list_data[key]:
                label = '[COLOR green]%s[/COLOR]' % (label)

        liz = utils.make_list_item(label, movie, local_utils.make_art(movie))
        liz.setInfo('video', movie)

        menu_items = []
        queries = {
            'mode': MODES.PLAY_RECENT,
            'movie_id': movie['movie_id'],
            'location': movie['location'],
            'thumb': movie.get('poster', '')
        }
        runstring = 'RunPlugin(%s)' % (kodi.get_plugin_url(queries))
        menu_items.append((i18n('play_most_recent'), runstring), )
        queries = {
            'mode': MODES.ADD_TRAKT,
            'title': movie['title'],
            'year': movie.get('year', '')
        }
        runstring = 'RunPlugin(%s)' % (kodi.get_plugin_url(queries))
        menu_items.append((i18n('add_to_trakt'), runstring), )
        runstring = 'RunPlugin(%s)' % (CP_ADD_URL % (movie['title']))
        menu_items.append((i18n('add_to_cp'), runstring), )
        liz.addContextMenuItems(menu_items, replaceItems=False)

        queries = {
            'mode': MODES.TRAILERS,
            'movie_id': movie['movie_id'],
            'location': movie['location'],
            'poster': movie.get('poster', ''),
            'fanart': movie.get('fanart', '')
        }
        liz_url = kodi.get_plugin_url(queries)
        xbmcplugin.addDirectoryItem(int(sys.argv[1]),
                                    liz_url,
                                    liz,
                                    isFolder=True)
    kodi.set_view('movies', set_sort=True)
    kodi.end_of_directory(cache_to_disc=False)
Example #4
0
def remote_play(source):
    rpc_client = HttpJSONRPC()
    command = {'jsonrpc': '2.0', 'id': 1, 'method': 'Player.GetActivePlayers'}
    response = rpc_client.execute_rpc(command)
    if 'error' in response:
        kodi.notify(kodi.get_name(), response['error'], duration=7000)
        return
    try:
        player_id = response['result'][0]['playerid']
    except IndexError:
        player_id = None
    if player_id == 2:  # stop picture player if active, it will block
        command = {'jsonrpc': '2.0', 'id': 1, 'method': 'Player.Stop', 'params': {'playerid': player_id}}
        response = rpc_client.execute_rpc(command)
        if 'error' in response:
            kodi.notify(kodi.get_name(), response['error'], duration=7000)
            return
    if source['is_dash']:
        filename = kodi.get_plugin_url({'mode': MODES.PLAY, 'player': 'false', 'path': urllib2.quote(source['url']),
                                        'thumb': urllib2.quote(source['art']['thumb']), 'title': urllib2.quote(source['info']['title'])})
    else:
        filename = source['url']
    command = {'jsonrpc': '2.0', 'id': 1, 'method': 'Player.Open', 'params': {'item': {'file': filename}}}
    response = rpc_client.execute_rpc(command)
    if 'error' in response:
        kodi.notify(kodi.get_name(), response['error'], duration=7000)
    else:
        if 'No Response' not in response['result']:
            kodi.notify(kodi.get_name(), kodi.i18n('send_success'))
Example #5
0
def make_directory(path, dir_name):
    menu_items = []
    queries = {'mode': MODES.DELETE_DIR, 'path': path, 'dir_name': dir_name}
    menu_items.append(('Delete Directory', 'RunPlugin(%s)' %
                       (kodi.get_plugin_url(queries))), )
    queries = {'mode': MODES.RENAME_DIR, 'path': path, 'dir_name': dir_name}
    menu_items.append(('Rename Directory', 'RunPlugin(%s)' %
                       (kodi.get_plugin_url(queries))), )
    path = os.path.join(path, dir_name)
    kodi.create_item({
        'mode': MODES.OPEN_DIR,
        'path': path
    },
                     dir_name,
                     is_folder=True,
                     menu_items=menu_items)
Example #6
0
def set_related_url(mode, media_type, title, year):
    # pull title from infolabels if not provided (i.e. not a widget)
    if title is None:
        if media_type == VIDEO_TYPES.SEASON:
            title = xbmc.getInfoLabel('ListItem.TVShowtitle')
        else:
            title = xbmc.getInfoLabel('ListItem.Title')

    # year isn't provided (i.e not a widget)
    if year is None:
        if media_type == VIDEO_TYPES.SEASON:
            year = __get_show_year(title)

        if year is None:
            year = xbmc.getInfoLabel('ListItem.Year')

    title = re.sub('\s+\(\d{4}\)$', '', title)
    queries = {
        'mode': mode,
        'video_type': media_type,
        'title': title,
        'year': year,
        'trakt_id': 0
    }  # trakt_id set to 0, not used and don't have it
    if media_type == VIDEO_TYPES.SEASON:
        queries['season'] = xbmc.getInfoLabel('ListItem.Season')
    runstring = 'RunPlugin(plugin://plugin.video.salts%s)' % (
        kodi.get_plugin_url(queries))
    xbmc.executebuiltin(runstring)
Example #7
0
def make_link(index, link, label, path):
    menu_items = []
    queries = {'mode': MODES.DELETE_LINK, 'index': index, 'path': path}
    menu_items.append(
        ('Delete Link', 'RunPlugin(%s)' % (kodi.get_plugin_url(queries))), )
    queries = {'mode': MODES.EDIT_LINK, 'index': index, 'path': path}
    menu_items.append(
        ('Edit Link', 'RunPlugin(%s)' % (kodi.get_plugin_url(queries))), )
    kodi.create_item({
        'mode': MODES.PLAY_LINK,
        'link': link
    },
                     label,
                     is_folder=False,
                     is_playable=True,
                     menu_items=menu_items)
Example #8
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()
Example #9
0
def main_menu():
    kodi.create_item({'mode': MODES.ADD_LINK}, 'Add Link', is_folder=False, is_playable=False)
    kodi.create_item({'mode': MODES.SETTINGS}, 'URLResolver Settings', is_folder=False, is_playable=False)
    if os.path.exists(LINK_PATH):
        with open(LINK_PATH) as f:
            for i, line in enumerate(f):
                item = line.split('|')
                link = item[0].strip()
                if not link: continue
                try:
                    label = item[1]
                except:
                    label = item[0]
                queries = {'mode': MODES.DELETE_LINK, 'index': i}
                menu_items = [('Delete Link', 'RunPlugin(%s)' % (kodi.get_plugin_url(queries))), ]
                queries = {'mode': MODES.EDIT_LINK, 'index': i}
                menu_items.append(('Edit Link', 'RunPlugin(%s)' % (kodi.get_plugin_url(queries))),)
                kodi.create_item({'mode': MODES.PLAY_LINK, 'link': link}, label, is_folder=False, is_playable=True, menu_items=menu_items)
    
    kodi.set_content('files')
    kodi.end_of_directory(cache_to_disc=False)
Example #10
0
def add_to_list():
    show_id = {'show_id': xbmc.getInfoLabel('ListItem.IMDBNumber')}
    if __get_media_type() == VIDEO_TYPES.TVSHOW:
        show_id['id_type'] = 'tvdb'
        section = SECTIONS.TV
    elif __get_media_type() == VIDEO_TYPES.MOVIE:
        show_id['id_type'] = 'tmdb'
        section = SECTIONS.MOVIES

    # override id_type if it looks like an imdb #
    if show_id['show_id'].startswith('tt'):
        show_id['id_type'] = 'imdb'
    
    if 'id_type' in show_id:
        queries = {'mode': MODES.ADD_TO_LIST, 'section': section}
        queries.update(show_id)
        runstring = 'RunPlugin(plugin://plugin.video.blamo%s)' % (kodi.get_plugin_url(queries))
        xbmc.executebuiltin(runstring)
Example #11
0
def search(section):
    queries = {'mode': MODES.SEARCH, 'section': section}
    runstring = 'RunPlugin(plugin://plugin.video.salts%s)' % (
        kodi.get_plugin_url(queries))
    xbmc.executebuiltin(runstring)
Example #12
0
def scraper_sort_order():
    queries = {'mode': MODES.SCRAPERS}
    runstring = 'RunAddon(plugin.video.salts,%s)' % (
        kodi.get_plugin_url(queries))
    xbmc.executebuiltin(runstring)