def trakt_play_random(list_items):
    import random
    random.seed()
    index = random.randint(0, len(list_items) - 1)
    list_item = list_items[index]
    if list_item['type'] == "show":
        id = list_item["show"]["ids"]["tvdb"]
        show_slug = list_item["show"]["ids"]["slug"]
        show_episodes = trakt.get_all_episodes(show_slug)
        season = show_episodes[random.randint(0, len(show_episodes) - 1)]
        episode = season["episodes"][random.randint(0, len(season) - 1)]
        season_number = episode["season"]
        episode_number = episode["number"]
        play_episode(id, season_number, episode_number, "default")
    elif list_item['type'] == "season":
        id = list_item["show"]["ids"]["tvdb"]
        show_slug = list_item["show"]["ids"]["slug"]
        season_number = list_item["season"]["number"]
        season_episodes = trakt.get_season_episodes(show_slug, season_number)
        episode = season_episodes[random.randint(0, len(season_episodes) - 1)]
        episode_number = episode["number"]
        play_episode(id, season_number, episode_number, "default")
    elif list_item['type'] == "episode":
        id = list_item["show"]["ids"]["tvdb"]
        season_number = list_item["season"]
        episode_number = list_item["number"]
        play_episode(id, season_number, episode_number, "default")
    elif list_item['type'] == "movie":
        id = list_item["movie"]["ids"]["tmdb"]
        play_movie(id, "default")
def tmdb_play_random(list_items):
    import random
    random.seed()
    index = random.randint(0, len(list_items) - 1)
    list_item = list_items[index]
    if list_item['type'] == "movie":
        id = list_item["id"]
        play_movie(id, "default")
Пример #3
0
def movies_play(src, id, mode="external"):
    import_tmdb()
    tmdb_id = None
    if src == "tmdb": tmdb_id = id
    elif src == "imdb":
        info = tmdb.Find(id).info(external_source="imdb_id")
        try: tmdb_id = info["movie_results"][0]["id"]
        except (KeyError, TypeError): pass
    if tmdb_id: play_movie(tmdb_id, mode)
    else: plugin.set_resolved_url()
Пример #4
0
def movies_play(src, id, mode):
    import_tmdb()
    tmdb_id = None
    if src == "tmdb": tmdb_id = id
    elif src == "imdb":
        info = tmdb.Find(id).info(external_source="imdb_id")
        try: tmdb_id = info["movie_results"][0]["id"]
        except (KeyError, TypeError): pass
    if tmdb_id: play_movie(tmdb_id, mode)
    else: plugin.set_resolved_url()