def tv_shows_episodes_menu(name, imdb_id): items = [] info = TheTVDBInfo(imdb_id) episodes = info.episodes() name = name.split('(')[0][:-1] for episode in episodes: first_aired = episode.FirstAired() if len(first_aired) > 0: d = first_aired.split('-') episode_date = date(int(d[0]), int(d[1]), int(d[2])) if date.today() > episode_date: season_number = int(episode.SeasonNumber()) if season_number > 0: episode_number = int(episode.EpisodeNumber()) episode_name = episode.EpisodeName() cleaned_name = clean_file_name(episode_name, use_blanks=False) display = "(S%.2dE%.2d) %s" % (season_number, episode_number, cleaned_name) data = "%s<|>%s<|>%d<|>%d" % (name, episode_name, season_number, episode_number) (url, li, isFolder) = create_item_tuple(display, 'episode dialog', data=data, imdb_id=imdb_id) li = set_tv_show_meta(li, imdb_id, META_PATH) li.setInfo('video', {'title': display}) items.append((url, li, isFolder)) #items.append((url, li, False)) return items
def create_item_tuple(name, mode, data="", imdb_id="", isFolder=True, isSubscribable=False, isMovieItem=False, isTVShowItem=False): url = create_url(name, mode, data, imdb_id) li = create_list_item(name, mode, isSubscribable=isSubscribable, isMovieItem=isMovieItem, isTVShowItem=isTVShowItem, imdb_id=imdb_id) if not imdb_id == "": if isMovieItem: li = set_movie_meta(li, imdb_id, META_PATH) if isTVShowItem: li = set_tv_show_meta(li, imdb_id, META_PATH) return (url, li, isFolder)
def episode_dialog(data, imdb_id=None, strm=False): dialog = xbmcgui.Dialog() open_playlists = dialog.yesno("Seach alternatives", "What search routine should be done?", "Regular search: Slow, but finds all results.", "Fast search: Fast but finds less files.", "Fast search", "Regular search") data = data.split('<|>') tv_show_name = data[0] episode_name = data[1] season_number = int(data[2]) episode_number = int(data[3]) season_episode = "s%.2de%.2d" % (season_number, episode_number) season_episode2 = "%d%.2d" % (season_number, episode_number) tv_show_season = "%s season" % (tv_show_name) tv_show_episode = "%s %s" % (tv_show_name, season_episode) track_filter = [episode_name, season_episode, season_episode2] files = [] files.extend(search(tv_show_episode, limit='25')) if open_playlists: files.extend(search(tv_show_season, limit='10')) files.extend(search(tv_show_name, limit='10')) files = remove_list_duplicates(files) pDialog = xbmcgui.DialogProgress() pDialog.create('Searching for files') tracks = [] count = 0 for f in files: count = count + 1 percent = int(float(count * 100) / len(files)) text = "%s files found" % len(tracks) pDialog.update(percent, text) if pDialog.iscanceled(): pDialog.close() if strm: set_resolved_to_dummy() return if f.av_result == "ok" and f.type == "video": new_tracks = filter_playlist_tracks(get_playlist_tracks(f, open_playlists=open_playlists), track_filter) tracks.extend(new_tracks) pDialog.close() (url, name) = track_dialog(tracks) if not url or not name: if strm: set_resolved_to_dummy() return li = xbmcgui.ListItem(clean_file_name(episode_name)) li = set_tv_show_meta(li, imdb_id, META_PATH) execute_video(name, url, li, strm)