Exemple #1
0
def root():
    """root menu of the addon"""
    if not get_list(root_xml_url):
        koding.Add_Dir(
            name=_("Message"),
            url=_("Sorry, server is down"),
            mode="message",
            folder=True,
            icon=xbmcaddon.Addon().getAddonInfo("icon"),
            fanart=xbmcaddon.Addon().getAddonInfo("fanart"),
            content_type="")
        koding.Add_Dir(
            name=_("Search"),
            url="",
            mode="Search",
            folder=True,
            icon=xbmcaddon.Addon().getAddonInfo("icon"),
            fanart=xbmcaddon.Addon().getAddonInfo("fanart"),
            content_type="")
        koding.Add_Dir(
            name=_("Testings"),
            url='{"file_name":"testings.xml"}',
            mode="Testings",
            folder=True,
            icon=xbmcaddon.Addon().getAddonInfo("icon"),
            fanart=xbmcaddon.Addon().getAddonInfo("fanart"),
            content_type="")
Exemple #2
0
def movies_add_to_library(src, id):
    """ Add movie to library """
    library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode))
    date = None
    if src == "tmdb":
        import_tmdb()
        movie = tmdb.Movies(id).info()
        date = date_to_timestamp(movie.get('release_date'))
        imdb_id = movie.get('imdb_id')
        if imdb_id:
            src = "imdb"
            id = imdb_id
    players = active_players("movies")
    if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True:
        player = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    else:
        players.insert(0, ADDON_SELECTOR)
        players.insert(0, ADDON_DEFAULT)
        selection = dialogs.select(_("Play using..."), [p.title for p in players])
        if selection == -1:
            return
        player = players[selection]
    # setup library folder
    library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode))
    # add to library
    if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True:
        add_movie_to_library(library_folder, src, id, play_plugin=plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode))
    else:
        add_movie_to_library(library_folder, src, id, play_plugin=player.id)
        dialogs.notify(msg=player.id, title=_("%s not found").replace("%s ",""), delay=3000, image=get_icon_path("movies"))
    scan_library(type="video")
Exemple #3
0
def tv():
    """ TV directory """
    items = [
        {
            'label': _("Search"),
            'path': plugin.url_for(tv_search),
            'icon': get_icon_path("search"),
        },
        {
            'label': _("Genres"),
            'path': plugin.url_for(tv_genres),
            'icon': get_icon_path("genres"),
        },
        {
            'label': _("Popular"),
            'path': plugin.url_for(tv_most_popular, page='1'),
            'icon': get_icon_path("popular"),
        },
        {
            'label': _("On the air"),
            'path': plugin.url_for(tv_now_playing, page='1'),
            'icon': get_icon_path("tv"),
        },
        {
            'label': _("Top rated"),
            'path': plugin.url_for(tv_top_rated, page='1'),
            'icon': get_icon_path("top_rated"),
        },
    ]
    
    fanart = plugin.addon.getAddonInfo('fanart')
    for item in items:
        item['properties'] = {'fanart_image' : fanart}

    return items
Exemple #4
0
def tv_play_by_name_only(name, lang):
    tvdb_id = get_tvdb_id_from_name(name, lang)
    if tvdb_id:
        season = None
        episode = None
        show = tv_tvshow(tvdb_id)

        while season is None or episode is None:  # don't exit completely if pressing back from episode selector
            selection = dialogs.select(_("Choose season"), [item["label"] for item in show])
            if selection != -1:
                season = show[selection]["info"]["season"]
                season = int(season)
            else:
                return
            items = []
            episodes = tv_season(tvdb_id, season)
            for item in episodes:
                label = "S{0}E{1} - {2}".format(item["info"]["season"], item["info"]["episode"],
                                                to_utf8(item["info"]["title"]))
                if item["info"]["plot"] is not None:
                    label += " - {0}".format(to_utf8(item["info"]["plot"]))
                items.append(label)
            selection = dialogs.select(_("Choose episode"), items)
            if selection != -1:
                episode = episodes[selection]["info"]["episode"]
                episode = int(episode)
                tv_play(tvdb_id, season, episode, "default")
Exemple #5
0
def make_tvshow_item(info):                        
    tvdb_id = info['tvdb_id']
    
    context_menu = [
     (   
      _("Add to library"),
      "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id))
     ),
     (
      _("Show info"), 'Action(Info)'
     ),
     (
      _("Add to list"),
      "RunPlugin({0})".format(plugin.url_for("lists_add_show_to_list", src='tvdb', id=tvdb_id,))
     )
    ]
             
    return {'label': info['title'],
            'path': plugin.url_for("tv_tvshow", id=tvdb_id),
            'context_menu': context_menu,
            'thumbnail': info['poster'],
            'icon': "DefaultVideo.png",
            'poster': info['poster'],
            'properties' : {'fanart_image' : info['fanart']},
            'info_type': 'video',
            'stream_info': {'video': {}},
            'info': info}
Exemple #6
0
def list_seasons_tvdb(id):
    import_tvdb()
    id = int(id)
    
    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)
    
    context_menu = [ ( _("Show info"), 'Action(Info)' ) ]
    
    items = []
    for (season_num, season) in show.items():
        if season_num == 0 or not season.has_aired():
            continue
        
        season_info = get_season_metadata_tvdb(show_info, season)
        
        items.append({'label': u"%s %d" % (_("Season"), season_num),
                      'path': plugin.url_for(tv_season, id=id, season_num=season_num),
                      'context_menu': context_menu,
                      'info': season_info,
                      'thumbnail': season_info['poster'],
                      'icon': "DefaultVideo.png",
                      'poster': season_info['poster'],
                      'properties' : {'fanart_image' : season_info['fanart']},
                      })
    return items
Exemple #7
0
def make_movie_item(movie_info):

    tmdb_id = movie_info['tmdb']
    
    context_menu = [
     (
       _("Select stream..."),
       "PlayMedia({0})".format(plugin.url_for("movies_play", src='tmdb', id=tmdb_id, mode='select'))
     ),                
     (
      _("Add to library"), 
      "RunPlugin({0})".format(plugin.url_for("movies_add_to_library", id=tmdb_id))
     ),
     (
      _("Show info"),
      'Action(Info)'
     ),
    ]
    
    return {'label': movie_info['title'],
            'path': plugin.url_for("movies_play", src='tmdb', id=tmdb_id, mode='default'),
            'context_menu': context_menu,
            'thumbnail': movie_info['poster'],
            'icon': "DefaultVideo.png",
            'poster': movie_info['poster'],
            'properties' : {'fanart_image' : movie_info['fanart']},
            'is_playable': True,
            'info_type': 'video',
            'info': movie_info}
Exemple #8
0
def play_channel_from_guide(channel, program, language, mode):
    # Get channelers to use
    if mode == 'select':
        play_plugin = ADDON_PICKER.id
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_LIVE_DEFAULT_CHANNELER, unicode)
    else:
        play_plugin = mode
    channelers = active_channelers("live")
    channelers = [p for p in channelers if p.id == play_plugin] or channelers
    if not channelers:
        dialogs.notify(msg="{0} {1} {2}".format(_("No cache").replace(_("Cache").lower(),_("TV")), _("Player").lower(), _("Enabled").lower()), title=_("Error"), delay=5000, image=get_icon_path("live"))
        action_cancel()
        return
    # Get parameters
    params = {}
    for lang in get_needed_langs(channelers):
        params[lang] = get_channel_parameters(channel, program, language)
        params[lang] = to_unicode(params[lang])
    # Go for it
    link = on_play_video(mode, channelers, params)
    if link:
        action_play({
            'label': channel,
            'path': link,
            'is_playable': True,
            'info_type': 'video',
        })
Exemple #9
0
def lists_trakt_liked_lists(page):
    lists, pages = trakt.trakt_get_liked_lists(page)
    items = []
    for list in lists:
        info = list["list"]
        name = info["name"]
        user = info["user"]["username"]
        slug = info["ids"]["slug"]
        items.append({
            'label': name,
            'path': plugin.url_for("lists_trakt_show_list", user = user, slug = slug),
            'context_menu': [
                (
                    _("Add list to library"),
                    "RunPlugin({0})".format(plugin.url_for("lists_trakt_add_all_to_library", user=user, slug=slug))
                )
            ],
            'icon': get_icon_path("traktlikedlists"),
        })
    if pages > page:
        items.append({
            'label': _("Next >>"),
            'path': plugin.url_for("lists_trakt_liked_lists", page = int(page) + 1),
            'icon': get_icon_path("traktlikedlists"),
        })
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
Exemple #10
0
def search(search_func, term = None):
    """ Search wrapper """
    external = False
    if plugin.id == xbmc.getInfoLabel('Container.PluginName'):
        # Skip if search item isn't currently selected    
        label = xbmc.getInfoLabel('ListItem.label')
        if label and not equals(label, _("Search")):
            return
    else:
        external = True

    if term is None:
        # Get search keyword
        search_entered = plugin.keyboard(heading=_("search for"))
        if not search_entered:
            return

    else:
        search_entered = term
    # Perform search
    url = plugin.url_for(search_func, term=search_entered, page='1')
    if external:
        xbmc.executebuiltin('ActivateWindow(10025,"plugin://%s/",return)' % plugin.id)
        xbmc.executebuiltin('Container.Update("%s")' % url)
    else:
        plugin.redirect(url)
Exemple #11
0
def trakt_movies_watchlist_to_library(preaprove = False, uncached = False):
    from trakt import trakt
    if preaprove  or dialogs.yesno(_("Scan item to library"), "{0}[CR]{1}".format(_("Add %s") % ("'{0} {1} {2}'".format("Trakt", _("movie"), _("Watchlist").lower())),_("Are you sure?"))):
        if uncached:
            movies_add_all_to_library(trakt.trakt_get_watchlist_uncached("movies"), True)
        else:
            movies_add_all_to_library(trakt.trakt_get_watchlist("movies"))
Exemple #12
0
def music_add_artist_to_library(artist_name):
    import math

    library_folder = setup_library(plugin.get_setting(SETTING_MUSIC_LIBRARY_FOLDER))
    album_results = lastfm.get_artist_top_albums(artist_name)
    total_albums = len(album_results)
    index = 0
    pDialog = xbmcgui.DialogProgress()
    pDialog.create(
        "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR]",
        _("{0} {1} {2}").format(_("Adding"), artist_name, _("to library")),
    )
    for album in album_results["album"]:
        album_name = to_utf8(album["name"])
        percent_done = int(math.floor((float(index) / total_albums) * 100))
        pDialog.update(
            percent_done, _("{0} {1} - {2} {3}").format(_("Adding"), artist_name, album_name, _("to library"))
        )
        track_results = lastfm.get_album_info(artist_name, album_name)
        for track in track_results["tracks"]["track"]:
            if pDialog.iscanceled():
                pDialog.update(0)
                return
            track_name = to_utf8(track["name"])
            add_music_to_library(library_folder, artist_name, album_name, track_name)
        index += 1
        pDialog.update(0)
    scan_library(type="music")
Exemple #13
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder):
        xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)
    if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder):
        xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a movies video source?"
        )
        if dialogs.yesno(_("Library setup"), msg):
            source_thumbnail = get_icon_path("movies")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Movies")
            source_content = '(\'{0}\',\'movies\',\'metadata.themoviedb.org\',\'\',2147483647,1,\'<settings><setting id="RatingS" value="TMDb" /><setting id="certprefix" value="Rated " /><setting id="fanart" value="true" /><setting id="keeporiginaltitle" value="false" /><setting id="language" value="{1}" /><setting id="tmdbcertcountry" value="us" /><setting id="trailer" value="true" /></settings>\',0,0,NULL,NULL)'.format(
                library_folder, LANG
            )
            add_source(source_name, library_folder, source_content, source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
Exemple #14
0
def update_players():
    url = plugin.get_setting(SETTING_PLAYERS_UPDATE_URL)
    if updater.update_players(url):
        plugin.notify(msg=_('Players'), title=_('Updated'), delay=1000, image=get_icon_path("player"))
    else:
        plugin.notify(msg=_('Players update'), title=_('Failed'), delay=1000, image=get_icon_path("player"))
    plugin.open_settings()
Exemple #15
0
def make_tvshow_item(tvdb_show, tmdb_show=None):
    tvdb_info = get_tvshow_metadata_tvdb(tvdb_show)
    tmdb_info = get_tvshow_metadata_tmdb(tmdb_show)
    
    info = {}
    info.update(tvdb_info)
    info.update(dict((k,v) for k,v in tmdb_info.iteritems() if v))
    
    # Prefer translated info
    if LANG != "en":
        for key in ('name', 'title', 'plot'):
            if is_ascii(info.get(key,'')) and not is_ascii(tvdb_info.get(key,'')):
                info[key] = tvdb_info[key]
                        
    tvdb_id = info['tvdb_id']
    
    context_menu = [
     (   
      _("Add to library"),
      "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id))
     ),
     (
      _("Show info"), 'Action(Info)'
     )
    ]
             
    return {'label': info['title'],
            'path': plugin.url_for(tv_tvshow, id=tvdb_id),
            'context_menu': context_menu,
            'thumbnail': info['poster'],
            'icon': "DefaultVideo.png",
            'poster': info['poster'],
            'properties' : {'fanart_image' : info['fanart']},
            'info_type': 'video',
            'info': info}
Exemple #16
0
def lists_trakt_add_liked_to_library():
    lists, pages = trakt.trakt_get_liked_lists(1)
    misc_ids = []
    movie_ids = []
    tv_ids = []
    import xbmcgui
    pDialog = xbmcgui.DialogProgress()
    pDialog.create('[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR]', 'Creating batch import files')
    for page in range(0, int(pages)):
        lists, ignore = trakt.trakt_get_liked_lists(page)
        list_number = 1
        if (pDialog.iscanceled()): return
        percent = (int(page) / int(pages)) * 100
        pDialog.update(int(percent), '{0} {1} of {2} ...        '.format(_("Scanning for new content"), page, pages))
        for list in lists:
            list_number += 1
            pDialog.update(int(percent), '{0} {1} of {2} ...        '.format(_("Scanning for new content"), page, pages), 'list {0} of {1} on page'.format(list_number, len(lists) + 1))
            info = list["list"]
            user = info["user"]["username"]
            slug = info["ids"]["slug"]
            items = lists_trakt_show_list(user, slug)
            list_misc_ids, list_movie_ids, list_tv_ids = batch_find_list_ids(items)
            write_list_id_files(list_misc_ids, list_movie_ids, list_tv_ids, slug, user)
            misc_ids.extend(list_misc_ids)
            movie_ids.extend(list_movie_ids)
            tv_ids.extend(list_tv_ids)
    pDialog.close()
    write_batch_id_files(tv_ids, movie_ids, misc_ids)
    dialogs.notify(msg='Generating', title='.strm-files', delay=3000, image=get_icon_path("metalliq"))
    xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/batch_add_to_library)")
Exemple #17
0
def lists_trakt_my_lists():
    lists = trakt.trakt_get_lists()
    items = []
    for list in lists:
        name = list["name"]
        user = list["user"]["username"]
        slug = list["ids"]["slug"]
        items.append({
            'label': name,
            'path': plugin.url_for("lists_trakt_show_list", user = user, slug = slug),
            'context_menu': [
                (
                    _("Scan item to library"),
                    "RunPlugin({0})".format(plugin.url_for("lists_trakt_add_all_to_library", user=user, slug=slug))
                ),
                (
                    "{0} ({1})".format(_("Play"), _("Random").lower()),
                    "RunPlugin({0})".format(plugin.url_for("lists_trakt_play_random", user=user, slug=slug))
                )
            ],
            'icon': get_icon_path("traktmylists"),
            'thumbnail': get_icon_path("traktmylists"),
        })
        fanart = plugin.addon.getAddonInfo('fanart')
        for item in items:
            item['properties'] = {'fanart_image' : get_background_path()}
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
Exemple #18
0
def root():
    """ Root directory """
    items = [
        {
            'label': _("Movies"),
            'path': plugin.url_for("movies"),
            'icon': get_icon_path("movies"),
        },
        {
            'label': _("TV Shows"),
            'path': plugin.url_for("tv"),
            'icon': get_icon_path("tv"),
        },
        {
            'label': _("Live"),
            'path': plugin.url_for("live"),
            'icon': get_icon_path("live"),
        },
        {
            'label': _("Lists"),
            'path': plugin.url_for("lists"),
            'icon': get_icon_path("lists"),
        }
    ]
    
    fanart = plugin.addon.getAddonInfo('fanart')
    for item in items:
        item['properties'] = {'fanart_image' : fanart}
        
    return items
Exemple #19
0
def settings_set_players(media):
    players = get_players(media)
    players = sorted(players,key=lambda player: player.clean_title.lower())

    # Get selection by user
    selected = None
    try:
        result = dialogs.multiselect(_("Enable players"), [p.clean_title for p in players])
        if result is not None:
            selected = [players[i].id for i in result]
    except:
        msg = "Kodi 16 required. Do you want to enable all players instead?"
        if dialogs.yesno(_("Warning"), _(msg)):
            selected = [p.id for p in players]
    
    if selected is not None:
        if media == "movies":
            plugin.set_setting(SETTING_MOVIES_ENABLED_PLAYERS, selected)
        elif media == "tvshows":
            plugin.set_setting(SETTING_TV_ENABLED_PLAYERS, selected)
        elif media == "live":
            plugin.set_setting(SETTING_LIVE_ENABLED_PLAYERS, selected)
        else:
            raise Exception("invalid parameter %s" % media)
    
    plugin.open_settings()
Exemple #20
0
def play_by_label(label):
    types = [_("Movies"), _("TV shows")]
    selection = dialogs.select(_("Choose season"), [item for item in types])
    if selection == 0:
        xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/play_by_name/{0}/en)".format(label))
    else:
        xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/play_by_name_only/{0}/en)".format(label))
Exemple #21
0
def trakt_get_device_token(device_codes):
    data = {"code": device_codes["device_code"], "client_id": CLIENT_ID, "client_secret": CLIENT_SECRET}

    start = time.time()
    expires_in = device_codes["expires_in"]
    progress_dialog = xbmcgui.DialogProgress()
    progress_dialog.create(
        _("Authenticate Trakt"),
        _("Please go to https://trakt.tv/activate and enter the code"),
        str(device_codes["user_code"]),
    )

    try:
        time_passed = 0
        while not xbmc.abortRequested and not progress_dialog.iscanceled() and time_passed < expires_in:
            try:
                response = call_trakt("oauth/device/token", data=data, with_auth=False)
            except requests.HTTPError, e:
                if e.response.status_code != 400:
                    raise e

                progress = int(100 * time_passed / expires_in)
                progress_dialog.update(progress)
                xbmc.sleep(max(device_codes["interval"], 1) * 1000)
            else:
                return response

            time_passed = time.time() - start

    finally:
        progress_dialog.close()
        del progress_dialog

    return None
Exemple #22
0
def update_players():
    url = plugin.get_setting(SETTING_PLAYERS_UPDATE_URL, converter=unicode)
    if updater.update_players(url):
        plugin.notify(msg=_("Players"), title=_("Updated"), delay=1000, image=get_icon_path("player"))
    else:
        plugin.notify(msg=_("Players update"), title=_("Failed"), delay=1000, image=get_icon_path("player"))
    plugin.open_settings()
Exemple #23
0
def search():
    """
    Open root search directory
    """
    versionspec = {
        "columns": {
            "version": "TEXT"
        }
    }
    koding.Create_Table("version", versionspec)

    search_spec = {
        "columns": {
            "term": "TEXT"
        }
    }

    koding.Create_Table("search", search_spec)
    terms = koding.Get_All_From_Table("search")
    if terms:
        koding.Add_Dir(name=_("Clear Search"), mode="clear_search",
                       folder=True,
                       icon=icon, fanart=fanart)
    for term in terms:
        label = term["term"]
        context_menu = [
            (_("Remove Search"),
             "RunPlugin({0})".format(get_addon_url(mode="remove_search",
                                                   url=label)))
        ]
        koding.Add_Dir(name=label, url=label, mode="do_search", folder=True,
                       icon=icon, fanart=fanart, context_items=context_menu)

    koding.Add_Dir(name=_("Add Search"), mode="add_search", folder=True,
                   icon=icon, fanart=fanart)
Exemple #24
0
def players_setup():
    xbmc.executebuiltin('SetProperty(running,totalmetalliq,home)')
    url = "https://api.github.com/repos/OpenELEQ/verified-metalliq-players/zipball"
    if updater.update_players(url): dialogs.notify(msg=_('Player'), title=_('Updated for %s') % _('Player'), delay=1000, image=get_icon_path("player"))
    else: dialogs.notify(msg=_('Player'), title=_('Failed for %s') % _('Player'), delay=1000, image=get_icon_path("player"))
    xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/settings/players/all/)")
    xbmc.executebuiltin('ClearProperty(running,home)')
    return True
Exemple #25
0
def music_artist_tracks(artist_name, page):
    artist_name = to_utf8(artist_name)
    results = lastfm.get_artist_top_tracks(artist_name, page)
    items = []
    for track in results["track"]:
        large_image = track["image"][-1]["#text"]
        track_name = to_utf8(track["name"])
        context_menu = [
            (
                _("Context player"),
                "PlayMedia({0})".format(
                    plugin.url_for("music_play_audio", artist_name=artist_name, track_name=track_name, mode="context")
                ),
            ),
            (
                _("Add to library"),
                "RunPlugin({0})".format(
                    plugin.url_for("music_add_to_library", artist_name=artist_name, track_name=track_name)
                ),
            ),
            (
                _("Musicvideo"),
                "PlayMedia({0})".format(
                    plugin.url_for("music_play_video", artist_name=artist_name, track_name=track_name, mode="default")
                ),
            ),
        ]
        if plugin.get_setting(SETTING_PREFERRED_MUSIC_TYPE) == "audio":
            item = {
                "label": track_name,
                "path": plugin.url_for("music_play_audio", artist_name=artist_name, track_name=track_name),
                "thumbnail": large_image,
                "icon": "DefaultMusic.png",
                "poster": large_image,
                "info_type": "music",
                "context_menu": context_menu,
            }
        else:
            item = {
                "label": track_name,
                "path": plugin.url_for("music_play_video", artist_name=artist_name, track_name=track_name),
                "thumbnail": large_image,
                "icon": "DefaultMusicVideo.png",
                "poster": large_image,
                "info_type": "music",
                "context_menu": context_menu,
            }
        items.append(item)
    if results["@attr"]["totalPages"] > page:
        items.append(
            {
                "label": _("Next >>"),
                "icon": get_icon_path("item_next"),
                "path": plugin.url_for(music_artist_tracks, artist_name=artist_name, page=int(page) + 1),
            }
        )
    return items
Exemple #26
0
def update_players():
    url = plugin.get_setting(SETTING_PLAYERS_UPDATE_URL)
    
    if updater.update_players(url):
        plugin.notify(msg=_('Players updated'), delay=1000)
    else:
        plugin.notify(msg=_('Failed to update players'), delay=1000)
    
    plugin.open_settings()
Exemple #27
0
def player_setup():
    xbmc.executebuiltin("SetProperty(running,totalmetalliq,home)")
    url = "https://api.github.com/repos/OpenELEQ/verified-metalliq-players/zipball"
    if updater.update_players(url):
        plugin.notify(msg=_("Players"), title=_("Updated"), delay=1000, image=get_icon_path("player"))
    else:
        plugin.notify(msg=_("Players update"), title=_("Failed"), delay=1000, image=get_icon_path("player"))
    xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/settings/players/all/)")
    xbmc.executebuiltin("ClearProperty(running,home)")
    return True
Exemple #28
0
def music_artist_album_tracks(artist_name, album_name):
    artist_name = to_utf8(artist_name)
    album_name = to_utf8(album_name)
    results = lastfm.get_album_info(artist_name, album_name)
    items = []
    for track in results["tracks"]["track"]:
        track_name = to_utf8(track["name"])
        track_number = track["@attr"]["rank"]
        image = results["image"][-1]["#text"]
        context_menu = [
            (
                _("Context player"),
                "PlayMedia({0})".format(
                    plugin.url_for("music_play_audio", artist_name=artist_name, track_name=track_name, mode="context")
                ),
            ),
            (
                _("Add to library"),
                "RunPlugin({0})".format(
                    plugin.url_for(
                        "music_add_to_library", artist_name=artist_name, track_name=track_name, album_name=album_name
                    )
                ),
            ),
            (
                _("Musicvideo"),
                "RunPlugin({0})".format(
                    plugin.url_for("music_play_video", artist_name=artist_name, track_name=track_name, mode="default")
                ),
            ),
        ]
        if plugin.get_setting(SETTING_PREFERRED_MUSIC_TYPE) == "audio":
            item = {
                "label": "{0}. {1}".format(track_number, track_name),
                "path": plugin.url_for("music_play_audio", artist_name=artist_name, track_name=track_name),
                "thumbnail": image,
                "icon": "DefaultMusic.png",
                "poster": image,
                "info_type": "music",
                "context_menu": context_menu,
            }
        else:
            item = {
                "label": "{0}. {1}".format(track_number, track_name),
                "path": plugin.url_for(
                    "music_play_video", artist_name=artist_name, album_name=album_name, track_name=track_name
                ),
                "thumbnail": image,
                "icon": "DefaultMusicVideo.png",
                "poster": image,
                "info_type": "music",
                "context_menu": context_menu,
            }
        items.append(item)
    return items
Exemple #29
0
def music_artist_tracks(artist_name, page):
    artist_name = to_utf8(artist_name)
    results = lastfm.get_artist_top_tracks(artist_name, page)
    items = []
    for track in results["track"]:
        large_image = track["image"][-1]["#text"]
        track_name = to_utf8(track["name"])
        context_menu = [
            (
                _("Context player"),
                "PlayMedia({0})".format(plugin.url_for("music_play_audio", artist_name=artist_name,
                                                       track_name=track_name, mode='context'))
            ),
            (
                _("Scan item to library"),
                "RunPlugin({0})".format(plugin.url_for("music_add_to_library", artist_name=artist_name,
                                                       track_name=track_name))
            ),
            (
                _("Musicvideo"),
                "PlayMedia({0})".format(plugin.url_for("music_play_video", artist_name=artist_name,
                                                       track_name=track_name, mode='default'))
            )
        ]
        if plugin.get_setting(SETTING_PREFERRED_MUSIC_TYPE, unicode) == "audio":
            item = {
                'label': track_name,
                'path': plugin.url_for("music_play_audio", artist_name=artist_name, track_name=track_name),
                'thumbnail': large_image,
                'icon': "DefaultMusic.png",
                'poster': large_image,
                'info_type': 'music',
                'context_menu': context_menu,
            }
        else:
            item = {
                'label': track_name,
                'path': plugin.url_for("music_play_video", artist_name=artist_name, track_name=track_name),
                'thumbnail': large_image,
                'icon': "DefaultMusicVideo.png",
                'poster': large_image,
                'info_type': 'music',
                'context_menu': context_menu,
            }
        items.append(item)
    if results["@attr"]["totalPages"] > page:
        items.append({
            'label': _("Next >>"),
            'icon': get_icon_path("item_next"),
            'path': plugin.url_for("music_artist_tracks", artist_name=artist_name, page=int(page) + 1)
        })
    if FORCE == True: plugin.set_view_mode(VIEW); return items
    else: return items
Exemple #30
0
def make_movie_item(movie_info, is_list = False):

    tmdb_id = movie_info.get('tmdb')
    imdb_id = movie_info.get('imdb')
    
    if tmdb_id:
        id = tmdb_id 
        src = 'tmdb'
    else:
        id = imdb_id 
        src = 'imdb'
    
    context_menu = [
     (
       _("Select stream..."),
       "PlayMedia({0})".format(plugin.url_for("movies_play", src=src, id=id, mode='select'))
     ),                
     (
      _("Add to library"), 
      "RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))
     ),
     (
      _("Add to list"),
      "RunPlugin({0})".format(plugin.url_for("lists_add_movie_to_list", src=src, id=id))
     ),
     (
      _("Show info"),
      'Action(Info)'
     ),
    ]

    if is_list:
        context_menu.append(
            (
                _("Remove from list"),
                "RunPlugin({0})".format(plugin.url_for("lists_remove_movie_from_list", src=src, id=id))
            )
        )

    
    return {
        'label': movie_info['title'],
        'path': plugin.url_for("movies_play", src=src, id=id, mode='default'),
        'context_menu': context_menu,
        'thumbnail': movie_info['poster'],
        'icon': "DefaultVideo.png",
        'poster': movie_info['poster'],
        'properties' : {'fanart_image' : movie_info['fanart']},
        'is_playable': True,
        'info_type': 'video',
        'stream_info': {'video': {}},
        'info': movie_info
    }
Exemple #31
0
def list_trakt_tvshows_trending_paginated(results, pages, page):
    from trakt import trakt
    results = sorted(results,key=lambda item: item["show"]["title"].lower().replace("the ", ""))
    genres_dict = trakt_get_genres()
    shows = [get_tvshow_metadata_trakt(item["show"], genres_dict) for item in results]
    items = [make_tvshow_item(show) for show in shows if show.get('tvdb_id')]
    nextpage = int(page) + 1
    if pages > page:
        items.append({
            'label': _("Next page").format() + "  >>  (%s/%s)" % (nextpage, pages),
            'path': plugin.url_for("trakt_tv_trending", page=int(page) + 1),
            'icon': get_icon_path("item_next"),
        })
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
Exemple #32
0
def root():
    """root menu of the addon"""
    if not get_list(root_xml_url):
        koding.Add_Dir(name=_("Message"),
                       url=_("Sorry, server is down"),
                       mode="message",
                       folder=True,
                       icon=xbmcaddon.Addon().getAddonInfo("icon"),
                       fanart=xbmcaddon.Addon().getAddonInfo("fanart"),
                       content_type="")
        koding.Add_Dir(name=_("Search"),
                       url="",
                       mode="Search",
                       folder=True,
                       icon=xbmcaddon.Addon().getAddonInfo("icon"),
                       fanart=xbmcaddon.Addon().getAddonInfo("fanart"),
                       content_type="")
        koding.Add_Dir(name=_("Testings"),
                       url='{"file_name":"testings.xml"}',
                       mode="Testings",
                       folder=True,
                       icon=xbmcaddon.Addon().getAddonInfo("icon"),
                       fanart=xbmcaddon.Addon().getAddonInfo("fanart"),
                       content_type="")
Exemple #33
0
def search(search_func):
    """ Search wrapper """
    external = False
    if plugin.id == xbmc.getInfoLabel('Container.PluginName'):
        # Skip if search item isn't currently selected
        label = xbmc.getInfoLabel('ListItem.label')
        if label and not equals(label, _("Search")):
            return
    else:
        external = True

    # Get search keyword
    search_entered = plugin.keyboard(heading=_("search for"))
    if not search_entered:
        return

    # Perform search
    url = plugin.url_for(search_func, term=search_entered, page='1')
    if external:
        xbmc.executebuiltin('ActivateWindow(10025,"plugin://%s/",return)' %
                            plugin.id)
        xbmc.executebuiltin('Container.Update("%s")' % url)
    else:
        plugin.redirect(url)
Exemple #34
0
def list_seasons_tvdb(id):
    import_tvdb()
    id = int(id)

    show = tvdb[id]
    show_info = get_tvshow_metadata_tvdb(show, banners=False)

    context_menu = [(_("Show info"), 'Action(Info)')]

    items = []
    for (season_num, season) in show.items():
        if season_num == 0 or not season.has_aired(flexible=True):
            continue

        season_info = get_season_metadata_tvdb(show_info, season)

        items.append({
            'label':
            u"%s %d" % (_("Season"), season_num),
            'path':
            plugin.url_for(tv_season, id=id, season_num=season_num),
            'context_menu':
            context_menu,
            'info':
            season_info,
            'thumbnail':
            season_info['poster'],
            'icon':
            "DefaultVideo.png",
            'poster':
            season_info['poster'],
            'properties': {
                'fanart_image': season_info['fanart']
            },
        })
    return items
Exemple #35
0
def get_tvdb_id_from_name(name, lang):
    import_tvdb()

    search_results = tvdb.search(name, language=lang)

    if not search_results:
        dialogs.ok(_("Show not found"), "{0} {1} in tvdb".format(_("no show information found for"), to_utf8(name)))
        return

    items = []
    for show in search_results:
        if "firstaired" in show:
            show["year"] = int(show['firstaired'].split("-")[0].strip())
        else:
            show["year"] = 0
        items.append(show)

    if len(items) > 1:
        selection = dialogs.select(_("Choose Show"), ["{0} ({1})".format(
            to_utf8(s["seriesname"]), s["year"]) for s in items])
    else:
        selection = 0
    if selection != -1:
        return items[selection]["id"]
Exemple #36
0
def auto_live_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("live")
            source_name = "MetalliQ " + _("Channels")
            source_content = "('{0}','','','',0,0,'<settings></settings>',0,0,NULL,NULL)".format(
                library_folder)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
            return True
        except:
            False
Exemple #37
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER,
                                         unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        msg = _(
            "Would you like to automatically set [COLOR yellow]chappaai[/COLOR] as a music source?"
        )
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            source_thumbnail = get_icon_path("musicvideos")
            source_name = "[COLOR yellow]chappaai[/COLOR] " + _("Music videos")
            source_content = "('{0}','musicvideos','metadata.musicvideos.theaudiodb.com','',2147483647,0,'<settings><setting id=\"fanarttvalbumthumbs\" value=\"true\" /><setting id=\"tadbalbumthumbs\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(
                library_folder)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
Exemple #38
0
def settings_set_default_player(media):
    players = active_players(media)
    players.insert(0, ADDON_SELECTOR)

    selection = dialogs.select(_("Select player"), [p.title for p in players])
    if selection >= 0:
        selected = players[selection].id
        if media == "movies":
            plugin.set_setting(SETTING_MOVIES_DEFAULT_PLAYER, selected)
        elif media == "tvshows":
            plugin.set_setting(SETTING_TV_DEFAULT_PLAYER, selected)
        else:
            raise Exception("invalid parameter %s" % media)

    plugin.open_settings()
Exemple #39
0
def get_info(items, dialog=None):
    from resources.lib.util.xml import totallyItem
    result = run_hook("get_info", items, dialog)
    if result:
        return result
    koding.reset_db()
    info = []
    num_items = len(items)
    for index, item_xml in enumerate(items):
        if dialog:
            if dialog.iscanceled():
                dialog.close()
                break
            percent = ((index + 1) * 100) / num_items
            dialog.update(percent, _("processing metadata"),
                          "%s of %s" % (index + 1, num_items))
        if type(item_xml) == dict:
            item = item_xml
        else:
            item = totallyItem(item_xml)
        item_info = {}
        content = item.get("content", "")
        try:
            if content == "movie":
                item_info = get_movie_metadata(item["imdb"])
            elif content in ["tvshow", "season"]:
                item_info = get_show_metadata(item["imdb"])
            elif content == "episode":
                item_info = get_episode_metadata(item["imdb"], item["season"],
                                                 item["episode"])
            if type(item_info) == list:
                item_info = {}
            if not item_info.get("plotoutline", None):
                item_info["plotoutline"] = item_info.get("plot", "")
        except Exception as e:
            koding.dolog("info error: " + repr(e))
        summary = item.get("summary", False)
        if summary:
            if not item_info or type(item_info) != dict:
                item_info = {}
            item_info["plot"] = summary
            item_info["manual"] = True

        info.append(item_info)
    if dialog:
        dialog.close()
    tvdb.clear_cache()
    return info
Exemple #40
0
def auto_music_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("musicvideos")
            source_name = "Chappaai "  + _("Music videos")
            source_content = "('{0}','musicvideos','metadata.musicvideos.theaudiodb.com','',2147483647,0,'<settings><setting id=\"fanarttvalbumthumbs\" value=\"true\" /><setting id=\"tadbalbumthumbs\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
Exemple #41
0
def save_view_mode(content):
    viewid = get_view_id()
    skin = xbmc.getSkinDir()
    koding.Create_Table("addonviews", view_spec)
    koding.Remove_From_Table(
        "addonviews", {"skin": skin,
                       "content": content})
    koding.Add_To_Table("addonviews", {
        "skin": skin,
        "content": content,
        "viewid": viewid,
    })
    icon = xbmcaddon.Addon().getAddonInfo('icon')
    xbmcgui.Dialog().notification(xbmcaddon.Addon().getAddonInfo('name'),
                                  _("View set for %s") % content,
                                  icon)
Exemple #42
0
def list_trakt_movie_items(results, pages, page):
    from trakt import trakt
    movies = [get_trakt_movie_metadata(item["movie"], None) for item in results]
    items = [make_movie_item(movie) for movie in movies]
    page = int(page)
    pages = int(pages)
    if pages > 1:
        args = caller_args()
        args['page'] = page + 1
        items.append({
            'label': "{0}  >>  ({1}/{2})".format(_("Next page"), page + 1, pages),
            'path': plugin.url_for(caller_name(), **args),
            'icon': get_icon_path("item_next"),
            'properties' : {'fanart_image' : get_background_path()}})
    if FORCE == True: return  plugin.finish(items=items, sort_methods=SORTRAKT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORTRAKT)
def live_add_to_library(channel, mode):
    if mode != None and plugin.get_setting(SETTING_LIVE_DEFAULT_AUTO_ADD,
                                           bool):
        player = mode
    else:
        players = active_players("live",
                                 filters={'network': channel.get('network')})
        players.insert(0, ADDON_SELECTOR)
        selection = dialogs.select(_("Play using..."),
                                   [p.title for p in players])
        if selection == -1:
            return
        player = players[selection]
    library_folder = setup_library(
        plugin.get_setting(SETTING_LIVE_LIBRARY_FOLDER, unicode))
    add_channel_to_library(library_folder, channel, player)
Exemple #44
0
def music_artist_album_tracks(artist_name, album_name):
    artist_name = to_utf8(artist_name)
    album_name = to_utf8(album_name)
    results = lastfm.get_album_info(artist_name, album_name)
    items = []
    for track in results["tracks"]["track"]:
        track_name = to_utf8(track["name"])
        track_number = track["@attr"]["rank"]
        image = results["image"][-1]["#text"]
        context_menu = [
            (
                "{0} {1} {2}...".format(_("Select"), _("Audio").lower(), _("Stream").lower()),
                "PlayMedia({0})".format(plugin.url_for("music_play_audio", artist_name=artist_name,
                                                       track_name=track_name, mode='context'))
            ),
            (
                _("Scan item to library"),
                "RunPlugin({0})".format(plugin.url_for("music_add_to_library", artist_name=artist_name,
                                                       track_name=track_name, album_name=album_name))
            ),
            (
                "{0} {1} {2}...".format(_("Select"), _("Video").lower(), _("Stream").lower()),
                "RunPlugin({0})".format(plugin.url_for("music_play_video", artist_name=artist_name,
                                                       track_name=track_name, mode='default'))
            )
        ]
        if plugin.get_setting(SETTING_PREFERRED_MUSIC_TYPE, unicode) == "audio":
            item = {
                'label': "{0}. {1}".format(track_number, track_name),
                'path': plugin.url_for("music_play_audio", artist_name=artist_name, track_name=track_name),
                'thumbnail': image,
                'icon': "DefaultMusic.png",
                'poster': image,
                'info_type': 'music',
                'context_menu': context_menu,
            }
        else:
            item = {
                'label': "{0}. {1}".format(track_number, track_name),
                'path': plugin.url_for("music_play_video", artist_name=artist_name, album_name=album_name, track_name=track_name),
                'thumbnail': image,
                'icon': "DefaultMusicVideo.png",
                'poster': image,
                'info_type': 'music',
                'context_menu': context_menu,
            }
        items.append(item)
    if FORCE == True: plugin.set_view_mode(VIEW); return items
    else: return items
Exemple #45
0
def auto_movie_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(library_folder):
        try:
            if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("movies")
            source_name = "MetalliQ " + _("Movies")
            source_content = "('{0}','movies','metadata.themoviedb.org','',2147483647,1,'<settings><setting id=\"RatingS\" value=\"TMDb\" /><setting id=\"certprefix\" value=\"Rated \" /><setting id=\"fanart\" value=\"true\" /><setting id=\"keeporiginaltitle\" value=\"false\" /><setting id=\"language\" value=\"{1}\" /><setting id=\"tmdbcertcountry\" value=\"us\" /><setting id=\"trailer\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
Exemple #46
0
def set_live_library_player(path):
    # get active players
    players = active_players("live")
    players.insert(0, ADDON_SELECTOR)
    players.insert(0, ADDON_DEFAULT)
    # let the user select one player
    selection = dialogs.select(_("Select default player"), [p.title for p in players])
    if selection == -1:
        return
    # get selected player
    player = players[selection]
    # Create play with file
    player_filepath = os.path.join(path, 'player.info')
    player_file = xbmcvfs.File(player_filepath, 'w')
    content = "{0}".format(player.id)
    player_file.write(content)
    player_file.close()
Exemple #47
0
def list_trakt_movies_trending_paginated(results, pages, page):
    from trakt import trakt
    results = sorted(results,key=lambda item: item["movie"]["title"].lower().replace("the ", ""))
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    movies = [get_trakt_movie_metadata(item["movie"], genres_dict) for item in results]
    items = [make_movie_item(movie) for movie in movies]
    page = int(page)
    pages = int(pages)
    if pages > page:
        items.append({
            'label': "{0}  >>  ({1}/{2})".format(_("Next page"), page + 1, pages),
            'path': plugin.url_for("trakt_movies_trending", page=page + 1),
            'icon': get_icon_path("item_next"),
            'properties' : {'fanart_image' : get_background_path()},
        })
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORTRAKT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORTRAKT)
Exemple #48
0
def browse_library_channels():
    items = [
        {
            'label': _("New channel"),
            'path': plugin.url_for(live_search),
            'icon': get_icon_path("search"),
        },
    ]
    library_channels = get_library_channels()
    if library_channels:
        for (index, library_channel) in enumerate(library_channels):
            if library_channel != None:
                items.append({
                    'label': str(library_channel),
                    'path': plugin.url_for(live_play, program="None", language="en", channel=library_channel, mode="library"),
                    'icon': get_icon_path("library"),
                })
    return items
Exemple #49
0
def root():
    """ Root directory """
    items = [{
        'label': _("Movies"),
        'path': plugin.url_for("movies"),
        'icon': get_icon_path("movies"),
        'thumbnail': get_icon_path("movies"),
    }, {
        'label': _("TV shows"),
        'path': plugin.url_for("tv"),
        'icon': get_icon_path("tv"),
        'thumbnail': get_icon_path("tv"),
    }, {
        'label': _("Music"),
        'path': plugin.url_for("music"),
        'icon': get_icon_path("music"),
        'thumbnail': get_icon_path("music"),
    }, {
        'label': _("TV channels"),
        'path': plugin.url_for("live"),
        'icon': get_icon_path("live"),
        'thumbnail': get_icon_path("live"),
    }, {
        'label':
        _("Playlists"),
        'path':
        plugin.url_for("lists"),
        'icon':
        get_icon_path("lists"),
        'thumbnail':
        get_icon_path("lists"),
        'context_menu': [(_("Scan item to library"), "RunPlugin({0})".format(
            plugin.url_for("lists_trakt_add_all_lists_to_library")))],
    }, {
        'label': _("Enter search string"),
        'path': plugin.url_for("root_search"),
        'icon': get_icon_path("search"),
        'thumbnail': get_icon_path("search"),
    }]
    fanart = plugin.addon.getAddonInfo('fanart')
    for item in items:
        item['properties'] = {'fanart_image': get_background_path()}
    if FORCE == True:
        plugin.set_view_mode(VIEW)
        return items
    else:
        return items
Exemple #50
0
def auto_tvshows_setup(library_folder):
    if library_folder[-1] != "/": library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)[-1] != "/":
        playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("tv")
            source_name = "Chappaai " + _("TV shows")
            source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(
                library_folder, LANG)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
            return True
        except:
            False
Exemple #51
0
def trakt_my_tv():
    """ TV directory """
    items = [
        {
            'label': _("Collection"),
            'path': plugin.url_for(trakt_tv_collection),
            'icon': get_icon_path("traktcollection"), # TODO
            'context_menu': [
                (
                    _("Add to library"),
                    "RunPlugin({0})".format(plugin.url_for(trakt_tv_collection_to_library))
                )
            ],
        },
        {
            'label': _("Watchlist"),
            'path': plugin.url_for(trakt_tv_watchlist),
            'icon': get_icon_path("traktwatchlist"), # TODO
            'context_menu': [
                (
                    _("Add to library"),
                    "RunPlugin({0})".format(plugin.url_for(trakt_tv_watchlist_to_library))
                )
            ],
        },
        {
            'label': _("Next episodes"),
            'path': plugin.url_for(trakt_tv_next_episodes),
            'icon': get_icon_path("traktnextepisodes"), # TODO
        },
        {
            'label': _("Calendar"),
            'path': plugin.url_for(trakt_tv_calendar),
            'icon': get_icon_path("traktcalendar"), # TODO
        },
        {
            'label': _("Recommendations"),
            'path': plugin.url_for(trakt_tv_recommendations),
            'icon': get_icon_path("traktrecommendations"),  # TODO
        }
    ]
    fanart = plugin.addon.getAddonInfo('fanart')
    for item in items:
        item['properties'] = {'fanart_image' : get_background_path()}
    if FORCE == True: plugin.set_view_mode(VIEW); return items
    else: return items
Exemple #52
0
def lists():
    """ Lists directory """
    items = [
        {
            'label':
            "{0} {1} (Trakt)".format("\"Liked\"",
                                     _("Playlists").lower()),
            'path':
            plugin.url_for("lists_trakt_liked_lists", page=1),
            'icon':
            get_icon_path("traktlikedlists"),
            'thumbnail':
            get_icon_path("traktlikedlists"),
            'context_menu':
            [(_("Scan item to library"), "RunPlugin({0})".format(
                plugin.url_for("lists_trakt_add_liked_to_library")))]
        },
        {
            'label':
            "{0} {1} (Trakt)".format(_("Watch your"),
                                     _("Playlists").lower()),
            'path':
            plugin.url_for("lists_trakt_my_lists"),
            'icon':
            get_icon_path("traktmylists"),
            'thumbnail':
            get_icon_path("traktmylists"),
            'context_menu':
            [(_("Scan item to library"), "RunPlugin({0})".format(
                plugin.url_for("lists_trakt_add_my_lists_to_library")))]
        },
        {
            'label': "{0}: {1} (Trakt)".format(_("Search"), _("Playlist")),
            'path': plugin.url_for("lists_trakt_search_for_lists"),
            'icon': get_icon_path("search"),
            'thumbnail': get_icon_path("search"),
        },
    ]
    fanart = plugin.addon.getAddonInfo('fanart')
    for item in items:
        item['properties'] = {'fanart_image': get_background_path()}
    if FORCE == True:
        plugin.set_view_mode(VIEW)
        return items
    else:
        return items
Exemple #53
0
def list_tmdb_movies(result):
    genres_dict = get_base_genres()
    movies = [
        get_movie_metadata(item, genres_dict) for item in result['results']
    ]
    items = [make_movie_item(movie) for movie in movies]

    if 'page' in result:
        page = result['page']
        args = caller_args()
        if page < result['total_pages']:
            args['page'] = str(page + 1)
            items.append({
                'label': _("Next >>"),
                'icon': get_icon_path("item_next"),
                'path': plugin.url_for(caller_name(), **args)
            })

    return items
Exemple #54
0
def settings_set_default_player_fromcontext(media):
    players = active_players(media)
    players.insert(0, ADDON_SELECTOR)
    selection = dialogs.select("{0}".format(_("Select %s") % "{0} {1}".format("context", _("Player").lower())), [p.title for p in players])
    if selection >= 0:
        selected = players[selection].id
        if media == "movies":
            plugin.set_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_CONTEXT, selected)
        elif media == "tvshows":
            plugin.set_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, selected)
        elif media == "musicvideos":
            plugin.set_setting(SETTING_MUSICVIDEOS_DEFAULT_PLAYER_FROM_CONTEXT, selected)
        elif media == "music":
            plugin.set_setting(SETTING_MUSIC_DEFAULT_PLAYER_FROM_CONTEXT, selected)
        elif media == "live":
            plugin.set_setting(SETTING_LIVE_DEFAULT_PLAYER_FROM_CONTEXT, selected)
        else:
            raise Exception("invalid parameter %s" % media)
    plugin.open_settings()
Exemple #55
0
def display_data(Items):
    for item in Items:
        context_items = []
        if ADDON.getSetting("settings_context") == "true":
            context_items.append(
                (_("Settings"),
                 "RunPlugin({0})".format(get_addon_url("Settings"))))
        context_items.extend(item["context"])
        koding.Add_Dir(name=item["label"],
                       url=item["url"],
                       mode=item["mode"],
                       folder=item["folder"],
                       icon=item["icon"],
                       fanart=item["fanart"],
                       context_items=context_items,
                       content_type="video",
                       info_labels=item["info"],
                       set_property=item.get("properties", {}),
                       set_art={"poster": item["icon"]})
Exemple #56
0
def list_tmdb_items(result):
    if FORCE == True: plugin.set_view_mode(VIEW)
    genres_dict = get_base_genres()
    movies = [get_movie_metadata(item, None) for item in result['results']]
    items = [make_movie_item(movie) for movie in movies]
    if 'page' in result:
        page = int(result['page'])
        pages = int(result['total_pages'])
        args = caller_args()
        if pages > page:
            args['page'] = str(page + 1)
            items.append({
                'label': "{0}  >>  ({1}/{2})".format(_("Next page"), page + 1, pages),
                'icon': get_icon_path("item_next"),
                'path': plugin.url_for(caller_name(), **args),
                'properties' : {'fanart_image' : get_background_path()},
            })
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
Exemple #57
0
def update_players(url=None):
    if url is None:
        url = plugin.get_setting(SETTING_PLAYERS_UPDATE_URL, unicode)
    if updater.update_players(url):
        dialogs.notify(msg=_('Update'),
                       title=_('Updated for %s') % _('Player'),
                       delay=1000,
                       image=get_icon_path("player"))
    else:
        dialogs.notify(msg=_('Update'),
                       title=_('Failed for %s') % _('Player'),
                       delay=1000,
                       image=get_icon_path("player"))
    plugin.open_settings()
Exemple #58
0
def lists_trakt_liked_lists(page):
    lists, pages = trakt.trakt_get_liked_lists(page)
    items = []
    for list in lists:
        info = list["list"]
        name = info["name"]
        user = info["user"]["username"]
        slug = info["ids"]["slug"]
        items.append({
            'label': name,
            'path': plugin.url_for("lists_trakt_show_list", user = user, slug = slug),
            'icon': get_icon_path("traktlikedlists"),  # TODO
        })
    if pages > page:
        items.append({
            'label': _("Next >>"),
            'path': plugin.url_for("lists_trakt_liked_lists", page = int(page) + 1),
            'icon': get_icon_path("traktlikedlists"),  # TODO
        })
    return items
Exemple #59
0
def update_players_remote(url):
    # Get username and password
    parsed = urlparse(url)
    username = parsed.username
    password = parsed.password
    if username is not None:
        if not password:
            password = plugin.keyboard(heading=_('Enter password'), hidden=True)
        if not password:
            return False        
        url = remove_auth(url)
        
    # Try without authentication            
    response = None
    try:
        response = urllib2.urlopen(url)
    except urllib2.HTTPError, e:
        if not username:
            return False
        url = e.geturl()
Exemple #60
0
def __replace_gif(url):
    """ put gifs in local cache
    try to put gif in cache to enable motion
    Keyword Arguments:
    url -- url pointing to gif
    """
    if not url.endswith(".gif"):
        return url
    else:
        base_folder = xbmcaddon.Addon().getSetting("cache_folder")
        dest_folder = os.path.join(xbmc.translatePath(base_folder), "artcache")
        xbmcvfs.mkdirs(dest_folder)
        parts = url.split("/")
        dest = xbmc.makeLegalFilename(
            # TODO make sure this is unique
            os.path.join(dest_folder, parts[-2] + parts[-1]))
        if not xbmcvfs.exists(dest):
            try:
                response = requests.get(url, timeout=10, verify=False)
            except:
                return None
            if response.status_code == 200:
                with open(dest, 'wb') as out_file:
                    data = response.content
                    response.close()
                    out_file.write(data)
                    # shutil.copyfileobj(response.raw, out_file)
                    del data
                    del response
                if os.path.getsize(dest) == 0:
                    koding.dolog("0 size gif: " + repr(dest))
                    os.remove(dest)
                    return None
                else:
                    koding.dolog("size: " + repr(os.path.getsize(dest)))
            else:
                koding.Text_Box(xbmcaddon.Addon().getAddonInfo('name'),
                                _("gif not found: ") + url)
                return None
        xbmc.log("gif done: " + repr(dest))
        return dest