def get_matches(self, video, hearing_impaired=False): matches = super(SubsCenterSubtitle, self).get_matches(video, hearing_impaired=hearing_impaired) # episode if isinstance(video, Episode): # series if video.series and sanitized_string_equal(self.series, video.series): matches.add('series') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # guess for release in self.releases: matches |= guess_matches(video, guessit(release, {'type': 'episode'})) # movie elif isinstance(video, Movie): # guess for release in self.releases: matches |= guess_matches(video, guessit(release, {'type': 'movie'})) # title if video.title and sanitized_string_equal(self.title, video.title): matches.add('title') return matches
def get_matches(self, video): matches = set() # series if video.series and sanitize(self.series) == sanitize(video.series): matches.add('series') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # year if video.original_series and self.year is None or video.year and video.year == self.year: matches.add('year') # release_group if video.release_group and self.release and video.release_group.lower() in self.release.lower(): matches.add('release_group') # other properties if self.release: matches |= guess_matches(video, guessit(self.release, {'type': 'episode'}), partial=True) if self.rip: matches |= guess_matches(video, guessit(self.rip), partial=True) return matches
def get_matches(self, video): matches = set() # series if video.series and sanitized_string_equal(self.series, video.series): matches.add("series") # season if video.season and self.season == video.season: matches.add("season") # episode if video.episode and self.episode == video.episode: matches.add("episode") # year if self.year == video.year: matches.add("year") # release_group if video.release_group and self.release and video.release_group.lower() in self.release.lower(): matches.add("release_group") # other properties if self.release: matches |= guess_matches(video, guessit(self.release, {"type": "episode"}), partial=True) if self.rip: matches |= guess_matches(video, guessit(self.rip), partial=True) return matches
def get_matches(self, video): matches = set() # episode if isinstance(video, Episode): # series if video.series and sanitized_string_equal(self.title, video.series): matches.add('series') # year if video.year == self.year: matches.add('year') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # guess for release in self.releases: matches |= guess_matches(video, guessit(release, {'type': 'episode'})) # movie elif isinstance(video, Movie): # title if video.title and sanitized_string_equal(self.title, video.title): matches.add('title') # year if video.year and self.year == video.year: matches.add('year') # guess for release in self.releases: matches |= guess_matches(video, guessit(release, {'type': 'movie'})) return matches
def get_matches(self, video): matches = set() # series if video.series and (sanitize(self.series) in ( sanitize(name) for name in [video.series] + video.alternative_series)): matches.add('series') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # year if video.original_series and self.year is None or video.year and video.year == self.year: matches.add('year') # release_group if (video.release_group and self.release and any(r in sanitize_release_group(self.release) for r in get_equivalent_release_groups(sanitize_release_group(video.release_group)))): matches.add('release_group') # other properties if self.release: matches |= guess_matches(video, guessit(self.release, {'type': 'episode'}), partial=True) if self.rip: matches |= guess_matches(video, guessit(self.rip), partial=True) return matches
def get_matches(self, video): matches = set() # episode if isinstance(video, Episode): # series if video.series and (sanitize(self.title) in ( sanitize(name) for name in [video.series] + video.alternative_series)): matches.add('series') # year if video.original_series and self.year is None or video.year and video.year == self.year: matches.add('year') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # guess for release in self.releases: matches |= guess_matches(video, guessit(release, {'type': 'episode'})) # movie elif isinstance(video, Movie): # title if video.title and (sanitize(self.title) in ( sanitize(name) for name in [video.title] + video.alternative_titles)): matches.add('title') # year if video.year and self.year == video.year: matches.add('year') # guess for release in self.releases: matches |= guess_matches(video, guessit(release, {'type': 'movie'})) return matches
def get_matches(self, video): matches = set() # episode if isinstance(video, Episode): # series if video.series and sanitize(self.series) == sanitize(video.series): matches.add('series') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # imdb_id if video.series_imdb_id and self.imdb_id == video.series_imdb_id: matches.add('series_imdb_id') # guess for release in self.releases: matches |= guess_matches(video, guessit(release, {'type': 'episode'})) # movie elif isinstance(video, Movie): # guess for release in self.releases: matches |= guess_matches(video, guessit(release, {'type': 'movie'})) # title if video.title and sanitize(self.title) == sanitize(video.title): matches.add('title') return matches
def get_matches(self, video): matches = set() if self.release_info.strip() == get_video_filename(video): logger.debug("Using hash match as the release name is the same") matches |= {"hash"} # episode if isinstance(video, Episode): guess = guessit(self.release_info, {'type': 'episode'}) self.season = guess.get("season") self.episode = guess.get("episode") matches |= guess_matches(video, guess) if "season" in matches and "episode" not in guess: # pack matches.add("episode") logger.debug("%r is a pack", self) self.is_pack = True # movie else: guess = guessit(self.release_info, {'type': 'movie'}) matches |= guess_matches(video, guess) if video.release_group and "release_group" not in matches and "release_group" in guess: if sanitize_release_group(video.release_group) in sanitize_release_group(guess["release_group"]): matches.add("release_group") self.matches = matches return matches
def get_paths_files(path, to_clean=True): """ return all the files under the path given :param path: root folder :return: return all the files under the path given """ files = [] for root, directories, file_names in os.walk(path): for filename in file_names: files.append(os.path.join(root, filename)) vid_with_data = {} for f in files: file_name = os.path.splitext(f)[0] for torrent_group in TORRENTS_GROUPS: if file_name.lower().endswith(torrent_group.lower()): os.rename(f, rreplace(f, torrent_group, "")) f = rreplace(f, torrent_group, "") break ext = os.path.splitext(f)[1] size_file = os.path.getsize(f) if ext in VIDEO_EXT: if size_file < 30 * MB or os.path.splitext(os.path.basename(f))[0] == "sample": if to_clean: os.remove(f) else: data = guessit(f) if to_clean: if isinstance(data["title"], list): folderName = data["title"][0] else: folderName = data["title"] if "year" in list(data.keys()): folderName += " - " + str(data["year"]) newPath = os.path.join(path, folderName) try: os.makedirs(newPath) except: pass shutil.move(f, os.path.join(newPath, f.split("\\")[-1])) vid_with_data[os.path.join(newPath, f.split("\\")[-1])] = guessit(f) else: vid_with_data[f] = guessit(f) elif ext in SUB_EXT: # This is probably mean that this is english sub, so delete if to_clean: os.remove(f) else: if size_file < 750 * KB: if to_clean: os.remove(f) if to_clean: clean_empty_dirs(path) return vid_with_data
def get_matches(self, video): matches = set() # episode if isinstance(video, Episode) and self.movie_kind == 'episode': # series if video.series and sanitize(self.series_name) == sanitize(video.series): matches.add('series') # year if video.original_series and self.movie_year is None or video.year and video.year == self.movie_year: matches.add('year') # season if video.season and self.series_season == video.season: matches.add('season') # episode if video.episode and self.series_episode == video.episode: matches.add('episode') # title if video.title and sanitize(self.series_title) == sanitize(video.title): matches.add('title') # guess matches |= guess_matches(video, guessit(self.movie_release_name, {'type': 'episode'})) # hash if 'opensubtitles' in video.hashes and self.hash == video.hashes['opensubtitles']: if 'series' in matches and 'season' in matches and 'episode' in matches: matches.add('hash') else: logger.debug('Match on hash discarded') # movie elif isinstance(video, Movie) and self.movie_kind == 'movie': # title if video.title and sanitize(self.movie_name) == sanitize(video.title): matches.add('title') # year if video.year and self.movie_year == video.year: matches.add('year') # guess matches |= guess_matches(video, guessit(self.movie_release_name, {'type': 'movie'})) # hash if 'opensubtitles' in video.hashes and self.hash == video.hashes['opensubtitles']: if 'title' in matches: matches.add('hash') else: logger.debug('Match on hash discarded') else: logger.info('%r is not a valid movie_kind', self.movie_kind) return matches # imdb_id if video.imdb_id and self.movie_imdb_id == video.imdb_id: matches.add('imdb_id') return matches
def metadata_anime_lookup(db, media_file_path): # check tv show data metadata_uuid, imdb_id, tmdb_id = nfo_xml_db_lookup_tv(db, nfo_data, xml_data) if metadata_uuid is None: metadata_uuid = tveps_lookup(guessit(media_file_path), imdb_id, tvdb_id, 'en') if metadata_uuid is None: # check movie data metadata_uuid, imdb_id, tmdb_id = nfo_xml_db_lookup(db, nfo_data, xml_data) if metadata_uuid is None: metadata_uuid = movie_lookup(guessit(media_file_path), imdb_id, tmdb_id) # TODO or perhaps JMM hit # TODO hit anidb return metadata_uuid
def get_filename_info(path_): videos_info = [] if os.path.isdir(path_): for root, dirs, files in os.walk(path_): videos_info += [{'video_info': dict(guessit(f)), 'file_path': os.path.join(root, f)} for f in files] elif os.path.isfile(path_): videos_info.append(guessit(os.path.basename(path_))) if videos_info: videos_info = filter(lambda md: 'video/' in md.get('video_info', {}).get('mimetype', []), videos_info) return videos_info
def test_should_add_new_piece_to_local_and_remote_collection(self, mock_add, *mocks): user = User(email="*****@*****.**", password="******", username="******") crawler = PieceCrawler(path="some/path", user=user) piece_1_path = "/etc/movie/jumanji-1995.mkv" piece_2_path = "/etc/movie/Dikkenek (2006).avi" crawler.on_created(FileSystemEvent(piece_1_path)) crawler.on_created(FileSystemEvent(piece_2_path)) self.assertEqual([ Piece(path=piece_1_path, guess=guessit.guessit(piece_1_path)), Piece(path=piece_2_path, guess=guessit.guessit(piece_2_path)), ], crawler.local_collection().piece_list()) self.assertEqual(2, mock_add.call_count)
def get_info(filename,filepath,movie_data): #creats data about the video item = guessit(filename) #is guessig movie name #print("B",item) print ("\t", filename) if item["type"] not in movie_data: movie_data[item["type"]] = {} if item["type"] == "movie": #data structure: #{"title--year":{"title":title,"year":year,"path":[path]}} title = get_info_property(item,filepath,"title") print ("\t\t", title) year = get_info_property(item,filepath,"year") if title+"--"+year not in movie_data[item["type"]]: movie_data[item["type"]][title+"--"+year]={} movie_data[item["type"]][title+"--"+year]["title"]=title movie_data[item["type"]][title+"--"+year]["year"]=year movie_data[item["type"]][title+"--"+year]["path"]=[filepath] else: movie_data[item["type"]][title+"--"+year]["path"].append(filepath) print ("\t\t", movie_data[item["type"]][title+"--"+year]["path"]) elif item["type"] == "episode": #data structure: #{"title":{"season--year":season--year,"episode":episode,"path":[path]}} title = get_info_property(item,filepath,"title") year = get_info_property(item,filepath,"year") season = get_info_property(item,filepath,"season") episode = get_info_property(item,filepath,"episode") mother_folder = os.path.split(os.path.split(filepath)[0])[-1] if title.lower().find(get_info_property(guessit(mother_folder),mother_folder,"title").lower()) != -1:#for "friday night dinner" where each episode have uniqe series name but share name with folder title = get_info_property(guessit(mother_folder),mother_folder,"title") if title.lower() not in [x.lower() for x in list(movie_data[item["type"]].keys())]: #checks titles in lower case to avoid multiple entries movie_data[item["type"]][title] = {} elif title not in movie_data[item["type"]]: #if title exists but not in existing case the title in existinge case is given title = sorted(list(movie_data[item["type"]].keys()))[sorted([x.lower() for x in list(movie_data[item["type"]].keys())]).index(title.lower())] if season+"--"+year not in movie_data[item["type"]][title]: movie_data[item["type"]][title][season+"--"+year] = {} if episode not in movie_data[item["type"]][title][season+"--"+year]: movie_data[item["type"]][title][season+"--"+year]["episode"]=episode movie_data[item["type"]][title][season+"--"+year]["path"]=[filepath] else: movie_data[item["type"]][title][season+"--"+year]["path"].append(filepath) return movie_data
def guessit(self): full_data = cache.get(slugify(self.full)) if full_data is None: data = guessit.guessit(self.full) cache.set(slugify(self.full), dict(data.items())) full_data = data return full_data
def titleInformation(filename): """Finds the needed information to rename the show. Takes the filename and formats it with information from guessit. Current format: Title S01E01.filename Args: filename: The name of the file for it to be decoded and renamed. Returns: The new filename format. Raises: None """ name = guessit(filename) title = name['title'] season = name['season'] episode = name['episode'] file_ending = filename[len(filename) - 4:len(filename)] if int(season) < 10: season = "0{}".format(season) if int(episode) < 10: episode = "0{}".format(episode) filename = "{0} S{1}E{2}{3}".format(title, season, episode, file_ending) return filename
def get_matches(self, video): matches = set() # series if video.series and ( sanitize(self.series) == sanitize(fix_inconsistent_naming(video.series)) or sanitize(self.series) == sanitize(video.series)): matches.add('series') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # year if ('series' in matches and video.original_series and self.year is None or video.year and video.year == self.year): matches.add('year') # release_group if (video.release_group and self.version and any(r in sanitize_release_group(self.version) for r in get_equivalent_release_groups(sanitize_release_group(video.release_group)))): matches.add('release_group') # resolution if video.resolution and self.version and video.resolution in self.version.lower(): matches.add('resolution') # format if video.format and self.version and video.format.lower() in self.version.lower(): matches.add('format') # other properties matches |= guess_matches(video, guessit(self.release_info.encode("utf-8"))) return matches
def get_matches(self, video): matches = set() # series if video.series and sanitize(self.series) == sanitize(video.series): matches.add('series') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # title if video.title and sanitize(self.title) == sanitize(video.title): matches.add('title') # year if video.original_series and self.year is None or video.year and video.year == self.year: matches.add('year') # release_group if (video.release_group and self.version and any(r in sanitize_release_group(self.version) for r in get_equivalent_release_groups(sanitize_release_group(video.release_group)))): matches.add('release_group') # resolution if video.resolution and self.version and video.resolution in self.version.lower(): matches.add('resolution') # format if video.format and self.version and video.format.lower() in self.version.lower(): matches.add('format') # other properties matches |= guess_matches(video, guessit(self.version), partial=True) return matches
def get_matches(self, video): matches = set() # series if video.series and sanitized_string_equal(self.series, video.series): matches.add('series') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # title if video.title and sanitized_string_equal(self.title, video.title): matches.add('title') # year if video.year == self.year: matches.add('year') # release_group if video.release_group and self.version and video.release_group.lower() in self.version.lower(): matches.add('release_group') # resolution if video.resolution and self.version and video.resolution in self.version.lower(): matches.add('resolution') # format if video.format and self.version and video.format.lower() in self.version.lower(): matches.add('format') # other properties matches |= guess_matches(video, guessit(self.version), partial=True) return matches
def move_movie_to_library(self): movie_folder = parameters['movie']['movie_folder'] download_folders = parameters['general']['download_folders'].split(',') for download_folder in download_folders: for root, _, files in os.walk(download_folder): for f in files: file_ext = f.split(".")[-1] file_name = f[:len(f)-len(file_ext)-1] file_analyze = guessit.guessit(f) try: if 'video' in file_analyze['mimetype'] and file_analyze['type'] == 'movie' and not os.path.isfile(root+'//'+file_name+'.aria2'): #get movie subtitle getSubtitle.main(root+'//'+f) movie_year = str(file_analyze['year']) if not os.path.exists(movie_folder+movie_year): os.mkdir(movie_folder+movie_year) os.rename(root+'//'+f, movie_folder + movie_year+'//'+f) self.retrieve_movie_subtitle(movie_folder + movie_year, root, f) except KeyError: continue
def _impl(self, location): parser = reqparse.RequestParser() parser.add_argument('filename', action='store', required=True, help='Filename to parse', location=location) parser.add_argument('options', action='store', help='Guessit options', location=location) args = parser.parse_args() return guessit.guessit(args.filename, args.options)
def titleInformation(filename, extension): """Finds the needed information to rename the show. Takes the filename and formats it with information from guessit. Current format: Title S01E01.filename Args: filename: The name of the file for it to be decoded and renamed. length: length of the filename Returns: The new filename format. Raises: None """ name = guessit(filename) title = name['title'] season = name['season'] episode = name['episode'] season = "{0:0>2}".format(name['season']) episode = "{0:0>2}".format(name['episode']) filename = "{0} S{1}E{2}{3}".format(title, season, episode, extension) return filename
def get_matches(self, video): matches = set() # series if video.series and sanitize(self.series) == sanitize(video.series): matches.add("series") # season if video.season and self.season == video.season: matches.add("season") # episode if video.episode and self.episode == video.episode: matches.add("episode") # title if video.title and sanitize(self.title) == sanitize(video.title): matches.add("title") # year if video.original_series and self.year is None or video.year and video.year == self.year: matches.add("year") # release_group if video.release_group and self.version and video.release_group.lower() in self.version.lower(): matches.add("release_group") # resolution if video.resolution and self.version and video.resolution in self.version.lower(): matches.add("resolution") # format if video.format and self.version and video.format.lower() in self.version.lower(): matches.add("format") # other properties matches |= guess_matches(video, guessit(self.version), partial=True) return matches
def scan_video(path): """Scan a video from a `path`. :param str path: existing path to the video. :return: the scanned video. :rtype: :class:`~subliminal.video.Video` """ # check for non-existing path if not os.path.exists(path): raise ValueError('Path does not exist') # check video extension if not path.endswith(VIDEO_EXTENSIONS): raise ValueError('%r is not a valid video extension' % os.path.splitext(path)[1]) dirpath, filename = os.path.split(path) logger.info('Scanning video %r in %r', filename, dirpath) # guess video = Video.fromguess(path, guessit(path)) # size and hashes video.size = os.path.getsize(path) if video.size > 10485760: logger.debug('Size is %d', video.size) video.hashes['opensubtitles'] = hash_opensubtitles(path) video.hashes['shooter'] = hash_shooter(path) video.hashes['thesubdb'] = hash_thesubdb(path) video.hashes['napiprojekt'] = hash_napiprojekt(path) logger.debug('Computed hashes %r', video.hashes) else: logger.warning('Size is lower than 10MB: hashes not computed') return video
def tv_search_tvdb(db_connection, file_name, lang_code='en'): """ # tvdb search """ file_name = guessit(file_name) if type(file_name['title']) == list: file_name['title'] = common_string.com_string_guessit_list(file_name['title']) common_global.es_inst.com_elastic_index('info', {"meta tv search tvdb": str(file_name)}) metadata_uuid = None tvdb_id = None if THETVDB_CONNECTION is not None: if 'year' in file_name: tvdb_id = str(THETVDB_CONNECTION.com_thetvdb_search(file_name['title'], file_name['year'], lang_code, True)) else: tvdb_id = str(THETVDB_CONNECTION.com_thetvdb_search(file_name['title'], None, lang_code, True)) common_global.es_inst.com_elastic_index('info', {"response": tvdb_id}) if tvdb_id is not None: # # since there has been NO match whatsoever.....can "wipe" out everything # media_id_json = json.dumps({'thetvdb': tvdb_id}) # common_global.es_inst.com_elastic_index('info', {'stuff':"dbjson: %s", media_id_json) # check to see if metadata exists for TVDB id metadata_uuid = db_connection.db_metatv_guid_by_tvdb(tvdb_id) common_global.es_inst.com_elastic_index('info', {"db result": metadata_uuid}) common_global.es_inst.com_elastic_index('info', {'meta tv uuid': metadata_uuid, 'tvdb': tvdb_id}) return metadata_uuid, tvdb_id
def get_movie_details(file_name): movie = False movie_name = None movie_year = None extension = None try: details = guessit(file_name) except Exception as e: print (str(e)) print ("Guess! Guess it is not working ") return movie, movie_name, movie_year, extension if 'container' in details: try: if details['container'] in KNOWN_EXTENSIONS: movie = True extension = details['container'] # This must be a video file :) if 'year' in details: # has the year info use it movie_year = details['year'] if 'title' in details: movie_name = details['title'] except Exception as e: print (str(e)) print("Cannot Seem to get it right :)") return movie, movie_name, movie_year, extension
def rottenTomatosMoviesDataAPI(moviesName): ListOfDictRT = list() for movies in moviesName: moviesTitle = guessit(movies) URL = "http://api.rottentomatoes.com/api/public/v1.0/movies.json?apikey=ny97sdcpqetasj8a4v2na8va&q="+moviesTitle['title'] # print (URL) results = requests.get(URL) if results.status_code==200: intoJson = results.json() for items in intoJson["movies"]: if moviesTitle['title'].upper() == items['title'].upper(): if moviesTitle['year'] == items['year']: items['ratings'].pop('critics_rating',None) items['ratings'].pop('audience_rating',None) items['ratings']['movieName'] = moviesTitle['title'] print(items['ratings']) ListOfDictRT.append(items['ratings']) else: print("movies year not matched") else: print("no response from server for"+moviesTitle['title']) return ListOfDictRT # print (intoJson["movies"]["ratings"])
def fromname(cls, name): """Shortcut for :meth:`fromguess` with a `guess` guessed from the `name`. :param str name: name of the video. """ return cls.fromguess(name, guessit(name))
def get_matches(self, video, hearing_impaired=False): matches = set() # series if video.series and sanitize(self.series) == sanitize(video.series): matches.add('series') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # format if video.format and video.format.lower() in self.format.lower(): matches.add('format') if not video.format and not self.format: matches.add('format') # hash if 'itasa' in video.hashes and self.hash == video.hashes['itasa']: print('Hash %s' % video.hashes['itasa']) if 'series' in matches and 'season' in matches and 'episode' in matches: matches.add('hash') # other properties matches |= guess_matches(video, guessit(self.full_data), partial=True) return matches
def refine_video(video, episode): # try to enrich video object using information in original filename if episode.release_name: guess_ep = subliminal.Episode.fromguess(None, guessit(episode.release_name)) for name in vars(guess_ep): if getattr(guess_ep, name) and not getattr(video, name): setattr(video, name, getattr(guess_ep, name)) # Use sickrage metadata metadata_mapping = { 'episode': 'episode', 'release_group': 'release_group', 'season': 'season', 'series': 'show.name', 'series_imdb_id': 'show.imdbid', 'size': 'file_size', 'title': 'name', 'year': 'show.startyear' } def get_attr_value(obj, name): value = None for attr in name.split('.'): if not value: value = getattr(obj, attr, None) else: value = getattr(value, attr, None) return value for name in metadata_mapping: if not getattr(video, name) and get_attr_value(episode, metadata_mapping[name]): setattr(video, name, get_attr_value(episode, metadata_mapping[name])) elif episode.show.subtitles_sr_metadata and get_attr_value(episode, metadata_mapping[name]): setattr(video, name, get_attr_value(episode, metadata_mapping[name]))
def get_name(film_name): if 'season' in film_name: name = '' name_arr = film_name.split('-') for string in name_arr: if 'season' in string: name_last_index = name_arr.index(string) - 1 name = '-'.join(name_arr[:name_last_index]) break return name else: return guessit(film_name).get('title')
def pirate(badFolder, goodFolder): files = [] illegalFilenames = ["nfo", "png", "url", "idx", "txt", "jpg", "dat"] #onlyfiles = [f for f in os.listdir(badFolder) if os.path.isfile(join(badFolder, f))] for root, directory, file in os.walk(badFolder): if len(file) > 0 and file[0][-3:] not in illegalFilenames: files.append(file[0].encode('utf-8', errors='replace')) for file in files: print(guessit.guessit(file)) print(repr(file)) pass return badFolder
def orgasmise(): os.chdir(input) for root, directories, files in os.walk('.'): for file in files: full = os.path.join(root, file) if is_proper_media(file): print('PROC: ' + full) guess = guessit(full) magic(root, file, guess) else: print('SKIP: ' + full)
def get_matches(self, video): type_ = "movie" if isinstance(video, Movie) else "episode" matches = guess_matches(video, guessit(self.release_info, {"type": type_})) # episode if isinstance(video, Episode): # series if video.series and sanitize(self.series) == sanitize( video.series): matches.add('series') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # imdb_id if video.series_imdb_id and self.imdb_id and str( self.imdb_id) == str(video.series_imdb_id): matches.add('series_imdb_id') matches.add('series') matches.add('year') # year if ('series' in matches and video.original_series and self.year is None or video.year and video.year == self.year): matches.add('year') # movie elif isinstance(video, Movie): # title if video.title and (sanitize(self.series) in ( sanitize(name) for name in [video.title] + video.alternative_titles)): matches.add('title') # imdb_id if video.imdb_id and self.imdb_id == video.imdb_id: matches.add('imdb_id') matches.add('title') matches.add('year') # year if video.year and self.year == video.year: matches.add('year') # release_group if (video.release_group and self.version and any(r in sanitize_release_group(self.version) for r in get_equivalent_release_groups( sanitize_release_group(video.release_group)))): matches.add('release_group') self.matches = matches return matches
def get_matches(self, video): matches = set() matches |= guess_matches(video, guessit(self.filename)) subtitle_filename = self.filename # episode if isinstance(video, Episode): # already matched in search query matches.update(['title', 'series', 'season', 'episode', 'year']) # movie elif isinstance(video, Movie): # already matched in search query matches.update(['title', 'year']) # release_group if video.release_group and video.release_group.lower( ) in subtitle_filename: matches.add('release_group') # resolution if video.resolution and video.resolution.lower() in subtitle_filename: matches.add('resolution') # source formats = [] if video.source: formats = [video.source.lower()] if formats[0] == "web": formats.append("webdl") formats.append("webrip") formats.append("web ") for frmt in formats: if frmt.lower() in subtitle_filename: matches.add('source') break # video_codec if video.video_codec: video_codecs = [video.video_codec.lower()] if video_codecs[0] == "H.264": formats.append("x264") elif video_codecs[0] == "H.265": formats.append("x265") for vc in formats: if vc.lower() in subtitle_filename: matches.add('video_codec') break matches.add('hash') return matches
def handle(self, *args, **kwargs): results = [] for fansub, users in tqdm(NYAA_USERS.items()): f,_ = Fansub.objects.get_or_create(name=fansub) for user in users: offset = 1 while True: results_ = nyaa.search(user=user,offset=offset) if not results_: break offset +=1 results+=results_ for res in tqdm(results): flag_next = False for j in BYPASS: if j.lower() in res.title.lower(): flag_next = True break if flag_next: continue date = make_aware(res.date, is_dst=False) torrent,created = Torrent.objects.get_or_create(full=res.title, url=res.link.replace("download","view"), defaults=dict(download_url = res.link.replace("view","download"), date=date)) tqdm.write("%s %s " % (res.title, res.link )) full = res.title data = guessit.guessit(full, {"episode_prefer_number":True, 'expected_group':RELEASE_GROUPS}) title = data.get("title") kwargs_ = {} if title in MAL_ANIMES: search_title, mal_id = MAL_ANIMES[title] title = search_title kwargs_ = {'mal_id':mal_id} try: mal_data = mal(title,**kwargs_) except: continue anime,_ = Anime.objects.get_or_create(slug=slugify(data.get("title")), defaults={"title":data.get("title")}) release_group,_ = ReleaseGroup.objects.get_or_create(name=data.get("release_group")) mal_obj, _ = MALMeta.objects.get_or_create(mal_id=mal_data.id) mal_obj.title = mal_data.title mal_obj.image = mal_data.img mal_obj.synopsys = mal_data.synopsys mal_obj.resumen = mal_data.resumen mal_obj.synonyms = mal_data.synonyms mal_obj.title_en = mal_data.title_en mal_obj.status = mal_data.status mal_obj.save() meta,_ = MetaTorrent.objects.get_or_create( anime=anime, torrent=torrent, release_group=release_group, mal=mal_obj) meta.episode=data.get("episode", data.get("episode_title")) meta.format=data.get("format", data.get("screen_size")) meta.save()
def _get_subtitle_from_archive(archive, subtitle): _valid_names = [] for name in archive.namelist(): # discard hidden files # discard non-subtitle files if not os.path.split(name)[-1].startswith('.') and name.lower( ).endswith(SUBTITLE_EXTENSIONS): _valid_names.append(name) # archive with only 1 subtitle if len(_valid_names) == 1: logger.debug( "returning from archive: {} (single subtitle file)".format( _valid_names[0])) return archive.read(_valid_names[0]) # in archives with more than 1 subtitle (season pack) we try to guess the best subtitle file _scores = get_scores(subtitle.video) _max_score = 0 _max_name = "" for name in _valid_names: _guess = guessit(name) if 'season' not in _guess: _guess['season'] = -1 if 'episode' not in _guess: _guess['episode'] = -1 if isinstance(subtitle.video, Episode): logger.debug("guessing %s" % name) logger.debug("subtitle S{}E{} video S{}E{}".format( _guess['season'], _guess['episode'], subtitle.video.season, subtitle.video.episode)) if subtitle.video.episode != _guess[ 'episode'] or subtitle.video.season != _guess['season']: logger.debug('subtitle does not match video, skipping') continue matches = set() matches |= guess_matches(subtitle.video, _guess) _score = sum((_scores.get(match, 0) for match in matches)) logger.debug('srt matches: %s, score %d' % (matches, _score)) if _score > _max_score: _max_score = _score _max_name = name logger.debug("new max: {} {}".format(name, _score)) if _max_score > 0: logger.debug("returning from archive: {} scored {}".format( _max_name, _max_score)) return archive.read(_max_name) raise APIThrottled('Can not find the subtitle in the compressed file')
def check_today_torrents(last_state, session): """ Check all new torrents from today, and create a filtered list of torrent URLs, based on last_state. :param last_state: A map between each show and the last reported episode for it. :param session: The current mma-torrents session. :return: A list of torrents to download. """ logger.info('Checking today\'s torrents...') r = session.get(MMA_TORRENTS_BASE_URL + '/torrents-today.php') r.raise_for_status() if not r.content: logger.error( 'Got empty content from website! Skipping state update...') return last_state # Copy previous state and overwrite new stuff. new_state = deepcopy(last_state) for a in r.html.find('a'): href = a.attrs.get('href', '') title = a.attrs.get('title') if title and 'torrents-details.php' in href: # Check if the episode is new, and relevant. show = guessit(title) if _validate_show(show): episode_title = show.get('episode_title', '').lower() show_title = '{}{}'.format( show.get('title', '').lower(), ' - {}'.format(episode_title) if episode_title and 'vs' not in episode_title else '') show_state = last_state.get(show_title) if show_state: episode_number = show.get('season', 0) * 100 + show.get( 'episode', 0) if show_state['episode'] < episode_number: logger.info(f'New episode was found - {show}') torrent_id = href.split('id=')[1].split('&')[0] new_state[show_title] = { 'episode': episode_number, 'torrent': f'https://mma-torrents.com/download.php?id={torrent_id}' } else: logger.debug( 'Found an already existing episode - {}: Episode {}. Skipping...' .format(show_title, episode_number)) return new_state
def find_id(self, series, year, original_title): """ We need to find the id of the series at the following url: https://www.feliratok.info/index.php?term=SERIESNAME&nyelv=0&action=autoname Where SERIESNAME is a searchable string. The result will be something like this: [{"name":"DC\u2019s Legends of Tomorrow (2016)","ID":"3725"},{"name":"Miles from Tomorrowland (2015)","ID":"3789"} ,{"name":"No Tomorrow (2016)","ID":"4179"}] """ # Search for exact name url = self.server_url + "index.php?term=" + series + "&nyelv=0&action=autoname" # url = self.server_url + "index.php?term=" + "fla"+ "&nyelv=0&action=autoname" logger.info('Get series id from URL %s', url) r = self.session.get(url, timeout=10) # r is something like this: # [{"name":"DC\u2019s Legends of Tomorrow (2016)","ID":"3725"},{"name":"Miles from Tomorrowland (2015)","ID":"3789"} # ,{"name":"No Tomorrow (2016)","ID":"4179"}] results = r.json() # check all of the results: for result in results: try: # "name":"Miles from Tomorrowland (2015)","ID":"3789" result_year = re.findall(r"(?<=\()\d\d\d\d(?=\))", result['name'])[0] except IndexError: result_year = "" try: # "name":"Miles from Tomorrowland (2015)","ID":"3789" result_title = re.findall(r".*(?=\(\d\d\d\d\))", result['name'])[0] result_id = result['ID'] except IndexError: continue result_title = result_title.strip().replace("�", "").replace(" ", ".") guessable = result_title.strip() + ".s01e01." + result_year guess = guessit(guessable, {'type': "episode"}) if sanitize(original_title) == sanitize( guess['title'] ) and year and guess['year'] and year == guess['year']: # Return the founded id return result_id return None
def get_matches(self, video): matches = set() if video.year == self.year: matches.add('year') # episode if isinstance(video, Episode): info = guessit(self.version, {"type": "episode"}) # other properties matches |= guess_matches(video, info) # add year to matches if video doesn't have a year but series, season and episode are matched if not video.year and all(item in matches for item in ['series', 'season', 'episode']): matches |= {'year'} # movie elif isinstance(video, Movie): # other properties matches |= guess_matches(video, guessit(self.version, {"type": "movie"})) return matches
def scan_subtitle(path): if not os.path.exists(path): raise ValueError('Path does not exist') dirpath, filename = os.path.split(path) logger.info('Scanning subtitle %r in %r', filename, dirpath) # guess parent_path = path.strip(filename) subtitle = Subtitle.fromguess(parent_path, guessit(path)) return subtitle
def get(self): """Use guessit to `guess` a release name. Return the result as a dictionary. """ release = self.get_argument('release') if not release: return self._bad_request('Missing release name to guess') guess = guessit.guessit(release) return self._ok(data=dict(guess))
def check_option_plex(item): try: log = '' flag_download = False value = ModelSetting.get('option_plex') if value == '0': flag_download = True elif value == '1': if not item.plex_info: flag_download = True log += u'Plex에 없음' elif value == '2': if item.plex_info: if 'screen_size' not in item.guessit: log += u'화질 정보없음' flag_download = False elif 'source' not in item.guessit: flag_download = False log += u'소스 정보없음' else: current_score = LogicNormal.get_score( item.guessit['screen_size'].replace('p', ''), item.guessit['source']) if current_score == 0: log += 'Plex : 세부정보 알수 없어서 제외' else: score_list = [] for v in item.plex_info: for m in v['media']: s1 = m['info'].split('/')[0].strip() g = guessit(os.path.basename(m['file'])) s2 = '' if 'source' in g: s2 = g['source'] score_list.append( LogicNormal.get_score(s1, s2)) score_list = list(reversed(sorted(score_list))) logger.debug('%s %s ', current_score, score_list) if current_score <= score_list[0]: log += u'Plex : 영상점수[%s] 최고점[%s] 제외' % ( current_score, score_list[0]) else: flag_download = True log += u'Plex : 영상점수[%s] 최고점[%s]' % ( current_score, score_list[0]) else: flag_download = True log += u'Plex에 없음' item.log += u'16.Plex - %s : %s\n' % (log, flag_download) except Exception as e: logger.error('Exception:%s', e) logger.error(traceback.format_exc()) return flag_download
def _get_subtitle_from_archive(archive, subtitle): _valid_names = [] for name in archive.namelist(): # discard hidden files # discard non-subtitle files if not os.path.split(name)[-1].startswith(".") and name.lower( ).endswith(SUBTITLE_EXTENSIONS): _valid_names.append(name) # archive with only 1 subtitle if len(_valid_names) == 1: logger.debug( f"returning from archive: {_valid_names[0]} (single subtitle file)" ) return archive.read(_valid_names[0]) # in archives with more than 1 subtitle (season pack) we try to guess the best subtitle file _scores = get_scores(subtitle.video) _max_score = 0 _max_name = "" for name in _valid_names: _guess = guessit(name) if "season" not in _guess: _guess["season"] = -1 if "episode" not in _guess: _guess["episode"] = -1 if isinstance(subtitle.video, Episode): logger.debug("guessing %s" % name) logger.debug( f"subtitle S{_guess['season']}E{_guess['episode']} video " f"S{subtitle.video.season}E{subtitle.video.episode}") if (subtitle.video.episode != _guess["episode"] or subtitle.video.season != _guess["season"]): logger.debug("subtitle does not match video, skipping") continue matches = set() matches |= guess_matches(subtitle.video, _guess) _score = sum((_scores.get(match, 0) for match in matches)) logger.debug("srt matches: %s, score %d" % (matches, _score)) if _score > _max_score: _max_score = _score _max_name = name logger.debug(f"new max: {name} {_score}") if _max_score > 0: logger.debug( f"returning from archive: {_max_name} scored {_max_score}") return archive.read(_max_name) raise APIThrottled("Can not find the subtitle in the compressed file")
def get_matches(self, video, hearing_impaired=False): matches = set() # The best available information about a subtitle is its name. Using guessit to parse it. guess = guessit(self.name, {'type': self.type}) matches |= guess_matches(video, guess) # imdb_id match used only for movies if self.type == 'movie' and video.imdb_id and self.imdb_id == video.imdb_id: matches.add('imdb_id') return matches
def get_matches(self, video, hearing_impaired=False): matches = set() # episode if isinstance(video, Episode) and self.type == 'episode': # series if video.series and sanitize(self.title) == sanitize(video.series): matches.add('series') # year (year is based on season air date hence the adjustment) if video.original_series and self.year is None or video.year and video.year == self.year - self.season + 1: matches.add('year') # imdb_id if video.series_imdb_id and self.imdb_id == video.series_imdb_id: matches.add('series_imdb_id') # movie elif isinstance(video, Movie) and self.type == 'movie': # title if video.title and sanitize(self.title) == sanitize(video.title): matches.add('title') # year if video.year and self.year == video.year: matches.add('year') # imdb_id if video.imdb_id and self.imdb_id == video.imdb_id: matches.add('imdb_id') # archive name matches |= guess_matches( video, guessit(self.archive.name, {'type': self.type})) # name matches |= guess_matches(video, guessit(self.name, {'type': self.type})) return matches
def get_matches(self, video): """ patch: set guessit to single_value :param video: :return: """ matches = set() # episode if isinstance(video, Episode): # series if video.series: matches.add('series') # year if video.original_series and self.year is None or video.year and video.year == self.year: matches.add('year') # season if video.season and self.season == video.season: matches.add('season') # episode if video.episode and self.episode == video.episode: matches.add('episode') # guess matches |= guess_matches(video, guessit(self.version, {'type': 'episode', "single_value": True})) pass # movie elif isinstance(video, Movie): # title if video.title and (sanitize(self.title) in ( sanitize(name) for name in [video.title] + video.alternative_titles)): matches.add('title') # year if video.year and self.year == video.year: matches.add('year') # guess matches |= guess_matches(video, guessit(self.version, {'type': 'movie', "single_value": True})) self.matches = matches return matches
def get_keywords(cls, video_name): """ 解析视频名 Args: video_name: 视频文件名 Return: keywords: list info_dict: guessit原始结果 """ video_name = video_name.replace("[", "") video_name = video_name.replace("]", "") keywords = [] info_dict = guessit(video_name) # 若视频名中英混合,去掉字少的语言 title = info_dict["title"] c_pattern = "[\u4e00-\u9fff]" e_pattern = "[a-zA-Z]" c_num = len(re.findall(c_pattern, title)) e_num = len(re.findall(e_pattern, title)) if c_num > e_num: title = re.sub(e_pattern, "", title) else: title = re.sub(c_pattern, "", title) title = title.strip() base_keyword = title if info_dict.get("season"): base_keyword += " s%s" % str(info_dict["season"]).zfill(2) keywords.append(base_keyword) if info_dict.get("year") and info_dict.get("type") == "movie": keywords.append(str(info_dict["year"])) # 若为电影添加年份 if info_dict.get("episode"): keywords.append("e%s" % str(info_dict["episode"]).zfill(2)) if info_dict.get("source"): keywords.append(info_dict["source"].replace("-", "")) if info_dict.get("release_group"): keywords.append(info_dict["release_group"]) if info_dict.get("streaming_service"): service_name = info_dict["streaming_service"] short_names = cls.service_short_names.get(service_name.lower()) if short_names: keywords.append(short_names) if info_dict.get("screen_size"): keywords.append(str(info_dict["screen_size"])) # 对关键字进行 URL 编码 keywords = [quote(_keyword) for _keyword in keywords] return keywords, info_dict
def sort_keyword(self, name): """ 解析视频名 返回将各个关键字按重要度降序排列的列表,原始视频信息 """ name = name.replace('[', '') name = name.replace(']', '') keywords = [] info_dict = guessit(name) # 若视频名中英混合,去掉字少的语言 title = info_dict['title'] if py == 2: if sys.stdout.encoding == 'cp936': encoding = 'gbk' else: encoding = 'utf8' title = title.decode(encoding) c_pattern = u'[\u4e00-\u9fff]' e_pattern = u'[a-zA-Z]' c_num = len(re.findall(c_pattern, title)) e_num = len(re.findall(e_pattern, title)) if c_num > e_num: title = re.sub(e_pattern, '', title).encode('utf8') else: title = re.sub(c_pattern, '', title).encode('utf8') elif py == 3: c_pattern = '[\u4e00-\u9fff]' e_pattern = '[a-zA-Z]' c_num = len(re.findall(c_pattern, title)) e_num = len(re.findall(e_pattern, title)) if c_num > e_num: title = re.sub(e_pattern, '', title) else: title = re.sub(c_pattern, '', title) title = title.strip() base_keyword = title # if info_dict.get('year') and info_dict.get('type') == 'movie': # base_keyword += (' ' + str(info_dict['year'])) # 若为电影添加年份 if info_dict.get('season'): base_keyword += (' s%s' % str(info_dict['season']).zfill(2)) keywords.append(base_keyword) if info_dict.get('episode'): keywords.append(' e%s' % str(info_dict['episode']).zfill(2)) if info_dict.get('screen_size'): keywords.append(str(info_dict['screen_size'])) if info_dict.get('format'): keywords.append(info_dict['format']) if info_dict.get('release_group'): keywords.append(info_dict['release_group']) return keywords, info_dict
def add_torrents_from_folder(path: str, transmission_url: str, torrentleech_username: str, torrentleech_password: str, torrentleech_rss_key): tc = transmissionrpc.Client(transmission_url, port=9091, user='******', password='******') load_processed() for dirname in Path(path).glob('**'): matches = guessit.guessit(dirname.name) if matches.get('type') == 'episode' and len(matches.keys()) > 2: if any([ processed for processed in processeds if processed in str(dirname) ]): log_error( dirname.name, 'already downloaded as part of ' 'a season pack or already downloaded') continue filter_url = get_filter_url() login_request = login(torrentleech_username, torrentleech_password) query = normalize_unicode(dirname.name).replace(":", "") url = f'https://www.torrentleech.org/torrents/browse/list/query/{query}/{filter_url}' results = requests.get(url, headers=REQUEST_HEADERS, cookies=login_request.cookies).json() if results['numFound'] > 0: torrent = results['torrentList'][0] if not torrent['filename'] == f'{dirname.name}.torrent': log_error( dirname.name, f'Torrent {dirname.name} no download filename ' f'mismatch {torrent["filename"]} ' f'!= {dirname.name}.torrent') continue torrent_url = ( f'https://www.torrentleech.org/rss/download' f'/{torrent["fid"]}/{torrentleech_rss_key}/{torrent["filename"]}' ) download_path = str(dirname.parent).replace("/Volumes", "") tc.add_torrent(torrent_url, download_dir=download_path) log_success(dirname.name, download_path, dirname) else: log_error(dirname.name, 'no search results', action='no_download')
def match_title(monitor, title, res): r = monitor.release matches = Map(guessit(title)) attr = lambda key, target: matches.get(key).contains(target) search_name = canonicalize(r.effective_search_name) name = canonicalize(r.name) canonical_title = matches.get('title').map(canonicalize) return ((canonical_title.contains(search_name) or canonical_title.contains(name)) and (attr('screen_size', res) or (matches.get('screen_size').empty and res == '')) and ((attr('season', r.season) and attr('episode', r.episode)) or attr('date', r.airdate.date())))
def setType(path, args): if args.autotype == "yes": details = guessit(path) format = details['type'] if (format == "episode"): format = 'TV' else: format = 'Movie' else: print(path, "\n") print("What type of file are you uploading", "\n") format = input("Enter TV or Movie: ") args.format = format
def get_matches(self, video): matches = guess_matches( video, { 'title': self.series, 'season': self.season, 'episode': self.episode, 'year': self.year, 'release_group': self.release }) # other properties if self.release: matches |= guess_matches(video, guessit(self.release, {'type': 'episode'}), partial=True) if self.rip: matches |= guess_matches(video, guessit(self.rip, {'type': 'episode'}), partial=True) return matches
def guess_category(name): guess = guessit(name) if guess: if guess['type'] == 'episode': if 'other' in guess and 'xxx' in guess['other'].lower(): return 'private' return 'tv' return guess['type']
def use_guessit(file_path: str): try: return guessit.guessit(file_path) except guessit.api.GuessitException: # lazy import the notifier module # This codepath will not be executed 99.99% of the time, and importing notify # in the outer scope is expensive due to the categories parsing # It is unneeded when using the "trakts whitelist" command from trakt_scrobbler.notifier import notify logger.exception("Encountered guessit error.") notify("Encountered guessit error. File a bug report!", category="exception") return {}
def build(torrent: Torrent, basePath='/') -> str: guessedDict = guessit(torrent.name) path = '/'.join([basePath, guessedDict['title']]) if not TvShowPathBuilder.isFullSeason(guessedDict): season = 'Season ' + str(guessedDict['season']) path = '/'.join([path, season]) if not TvShowPathBuilder.hasSubfolder(torrent.files): torrentSubfolder = '.'.join(torrent.name.split('.')[0:-1]) path = '/'.join([path, torrentSubfolder]) return path.replace(' ', '.') + '/'
def get_matches(self, video): matches = set() video_filename = video.name video_filename = os.path.basename(video_filename) video_filename, _ = os.path.splitext(video_filename) video_filename = re.sub(r'\[\w+\]$', '', video_filename).strip().upper() subtitle_filename = self.filename subtitle_filename = os.path.basename(subtitle_filename) subtitle_filename, _ = os.path.splitext(subtitle_filename) subtitle_filename = re.sub(r'\[\w+\]$', '', subtitle_filename).strip().upper() if ((video_filename == subtitle_filename) or (self.single_file is True and video_filename in self.notes.upper())): matches.add('hash') if video.year and self.year == video.year: matches.add('year') if isinstance(video, Movie): if video.imdb_id and self.imdb_id == video.imdb_id: matches.add('imdb_id') matches |= guess_matches(video, guessit(self.title, {'type': self.type})) guess_filename = guessit(self.filename, video.hints) matches |= guess_matches(video, guess_filename) if isinstance(video, Movie) and (self.num_cds > 1 or 'cd' in guess_filename): # reduce score of subtitles for multi-disc movie releases return set() return matches
def search_subscene(title): film = subscene.search(title, "en", searchtype) for subtitle in film.subtitles: if subtitle.language == wanted_language: title = cleanchar(subtitle.title) subtitle_meta = guessit(title, guessit_options) subtitle_meta.setdefault('season', 1) subtitle_meta['filename'] = title subtitle_meta['subtitle_object'] = subtitle subtitle_meta['session_pack'] = subtitle_meta['type'] == 'episode' and ( 'episode' not in subtitle_meta or isinstance(subtitle_meta['episode'], list) ) yield subtitle_meta
def get_imdb_info(path): details = guessit(path) title = details['title'] if 'year' in details: title = "{} {}".format(title, details['year']) results = IMDb().search_movie(title) if len(results) == 0: bhdlogger.warn("Unable to find imdb") id = input("Please Enter imdb id: ") id = re.sub("https://www.imdb.com/title/", "", id) id = re.sub("tt", "", id) id = re.sub("/", "", id) results = IMDb().get_movie(id) bhdlogger.debug(results) if isinstance(results, list) != True: return results counter = 0 accept = 'No' bhdlogger.warn("Searching for movie/TV Show on IMDB\n") while accept != "Yes": if counter == 6: id = input("Pleases Enter imdb id: ") id = re.sub("https://www.imdb.com/title/", "", id) id = re.sub("tt", "", id) id = re.sub("/", "", id) results = IMDb().get_movie(id) return results title = results[counter]['title'] year = str(results[counter]['year']) t = f"{title} {{ Movie Released-{year}}}" print(t) options = ["Yes", "No"] if sys.platform != "win32": menu = TerminalMenu(options) menu_entry_index = menu.show() else: menu_entry_index = SelectionMenu.get_selection(options) accept = options[menu_entry_index] if accept == "No": counter = counter + 1 if accept == "No": id = input("Please Enter imdb id") id = re.sub("https://www.imdb.com/title/", "", id) id = re.sub("tt", "", id) id = re.sub("/", "", id) results = IMDb().get_movie(id) return results return results[counter]