def test_get_imdb_id(): indexer = MovieIndexer() # By title assert indexer.get_imdb_id_and_year(u'Southpaw', force_search=True, store_id=False) == ('tt1798684', 2015) # By title and year assert indexer.get_imdb_id_and_year(u'Southpaw', year=2015, force_search=True, store_id=False) == ('tt1798684', 2015) assert indexer.get_imdb_id_and_year(u'Joyeux Noël', year=2005, force_search=True, store_id=False) == ('tt0424205', 2005) # By alternative title assert indexer.get_imdb_id_and_year(u'Kyatapirâ', force_search=True, store_id=False) == ('tt1508290', 2010) # By alternative title and year assert indexer.get_imdb_id_and_year(u'Kyatapirâ', year=2010, force_search=True, store_id=False) == ('tt1508290', 2010) # By fallback search assert indexer.get_imdb_id_and_year(u'Bullet', year=2014, force_search=True, store_id=False) == ('tt2544734', 2014)
def test_get_imdb_id_from_movie_name_mapping(monkeypatch): monkeypatch.setattr('autosubliminal.MOVIENAMEMAPPING', {'southpaw (2015)': 'tt1798684'}) indexer = MovieIndexer() assert indexer.get_imdb_id_and_year(u'Southpaw', 2015, force_search=False, store_id=False) == ('tt1798684', 2015)
def test_get_imdb_id_from_cache_not_found(monkeypatch, mocker): monkeypatch.setattr('autosubliminal.MOVIENAMEMAPPING', {}) mocker.patch('autosubliminal.db.ImdbIdCacheDb.get_imdb_id', return_value=IMDB_ID_UNKNOWN) indexer = MovieIndexer() assert indexer.get_imdb_id_and_year(u'Southpaw', 2015, force_search=False, store_id=False) == (None, 2015)
def __init__(self): self.show_db = ShowDetailsDb() self.failed_shows_db = FailedShowsDb() self.show_episodes_db = ShowEpisodeDetailsDb() self.show_settings_db = ShowSettingsDb() self.failed_movies_db = FailedMoviesDb() self.movie_db = MovieDetailsDb() self.movie_settings_db = MovieSettingsDb() self.show_indexer = ShowIndexer() self.movie_indexer = MovieIndexer()
def test_get_movie_details(): indexer = MovieIndexer() movie_details = indexer.get_movie_details('tt1798684') assert movie_details is not None assert isinstance(movie_details, MovieDetails) assert movie_details.imdb_id == 'tt1798684' assert movie_details.title == 'Southpaw' assert movie_details.year == 2015 assert movie_details.overview is not None assert movie_details.poster is not None
def test_get_imdb_id_exception(mocker): mocker.patch('autosubliminal.indexer.MovieIndexer._search', side_effect=Exception) db_mock_delete = mocker.patch( 'autosubliminal.db.ImdbIdCacheDb.delete_imdb_id') db_mock_set = mocker.patch('autosubliminal.db.ImdbIdCacheDb.set_imdb_id') indexer = MovieIndexer() assert indexer.get_imdb_id_and_year(u'Southpaw', 2015, force_search=True, store_id=True) == (None, 2015) assert db_mock_delete.called assert db_mock_set.called
def test_get_imdb_id(): indexer = MovieIndexer() assert indexer.get_imdb_id_and_year(u'Southpaw', 2015, force_search=True, store_id=False) == ('tt1798684', 2015) assert indexer.get_imdb_id_and_year(u'Southpaw', force_search=True, store_id=False) == ('tt1798684', 2015) assert indexer.get_imdb_id_and_year(u'Joyeux Noël', 2005, force_search=True, store_id=False) == ('tt0424205', 2005) assert indexer.get_imdb_id_and_year(u'Kyatapirâ', 2010, force_search=True, store_id=False) == ('tt1508290', 2010)
def test_get_imdb_id_and_store_in_cache(mocker): search_result = TitleSearchResult(imdb_id='tt1798684', title='Southpaw', type='feature', year=2015) mocker.patch('autosubliminal.indexer.MovieIndexer._search', return_value=search_result) db_mock_delete = mocker.patch( 'autosubliminal.db.ImdbIdCacheDb.delete_imdb_id') db_mock_set = mocker.patch('autosubliminal.db.ImdbIdCacheDb.set_imdb_id') indexer = MovieIndexer() assert indexer.get_imdb_id_and_year(u'Southpaw', 2015, force_search=True, store_id=True) == ('tt1798684', 2015) assert db_mock_delete.called assert db_mock_set.called
# coding=utf-8 import os import autosubliminal from autosubliminal.fileprocessor import process_file from autosubliminal.indexer import ShowIndexer, MovieIndexer autosubliminal.SHOWINDEXER = ShowIndexer() autosubliminal.MOVIEINDEXER = MovieIndexer() def test_process_file_size_too_low(monkeypatch): # Monkey patch autosubliminal.MINVIDEOFILESIZE monkeypatch.setattr('autosubliminal.MINVIDEOFILESIZE', 10) # Test process_file dir_name = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'resources') result_dict = process_file(dir_name, 'Southpaw.2015.1080p.BluRay.x264.mkv') assert result_dict is None def test_process_episode_file_insufficient_guess(): # Test process_file dir_name = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'resources') result_dict = process_file(dir_name, 'Insufficient.guess.series.S1.mkv') assert result_dict is None def test_process_episode_file(mocker): # Mock get_tvdb_id call mocker.patch.object(autosubliminal.SHOWINDEXER, 'get_tvdb_id')
def initialize(): global CONFIGFILE, CONFIGVERSION, CONFIGUPGRADED, \ CACHEDIR, DEREFERURL, GITHUBURL, VERSIONURL, USERAGENT, SYSENCODING, TIMEOUT, WANTEDQUEUE, WANTEDQUEUELOCK, \ WEBSOCKETMESSAGEQUEUE, WEBSOCKETBROADCASTER, SCHEDULERS, SCANDISK, SCANLIBRARY, CHECKSUB, CHECKVERSION, \ DEVELOPER, \ TVDBAPIKEY, TVDBURL, IMDBURL, SHOWINDEXER, MOVIEINDEXER, \ DBFILE, DBVERSION, DBTIMESTAMPFORMAT, \ PYTHONVERSION, DAEMON, STARTED, PID, UUID, \ PATH, VIDEOPATHS, DEFAULTLANGUAGE, DEFAULTLANGUAGESUFFIX, ADDITIONALLANGUAGES, MANUALSEARCHWITHSCORING, \ SCANDISKINTERVAL, CHECKSUBINTERVAL, CHECKSUBDEADLINE, CHECKSUBDELTA, CHECKVERSIONINTERVAL, \ CHECKVERSIONAUTOUPDATE, SCANEMBEDDEDSUBS, SCANHARDCODEDSUBS, SKIPHIDDENDIRS, DETECTINVALIDSUBLANGUAGE, \ DETECTEDLANGUAGEPROBABILITY, MINVIDEOFILESIZE, MAXDBRESULTS, TIMESTAMPFORMAT, \ LIBRARYMODE, LIBRARYPATHS, SCANLIBRARYINTERVAL, \ LOGFILE, LOGLEVEL, LOGSIZE, LOGNUM, LOGHTTPACCESS, LOGEXTERNALLIBS, LOGDETAILEDFORMAT, LOGREVERSED, \ LOGLEVELCONSOLE, \ WEBSERVERIP, WEBSERVERPORT, WEBROOT, USERNAME, PASSWORD, LAUNCHBROWSER, \ SHOWMINMATCHSCORE, SHOWMINMATCHSCOREDEFAULT, SHOWMATCHSOURCE, SHOWMATCHQUALITY, SHOWMATCHCODEC, \ SHOWMATCHRELEASEGROUP, \ MOVIEMINMATCHSCORE, MOVIEMINMATCHSCOREDEFAULT, MOVIEMATCHSOURCE, MOVIEMATCHQUALITY, MOVIEMATCHCODEC, \ MOVIEMATCHRELEASEGROUP, \ SUBLIMINALPROVIDERMANAGER, SUBLIMINALPROVIDERS, SUBLIMINALPROVIDERCONFIGS, \ SUBTITLEUTF8ENCODING, MANUALREFINEVIDEO, REFINEVIDEO, PREFERHEARINGIMPAIRED, \ ADDIC7EDUSERNAME, ADDIC7EDPASSWORD, OPENSUBTITLESUSERNAME, OPENSUBTITLESPASSWORD, \ SHOWNAMEMAPPING, ADDIC7EDSHOWNAMEMAPPING, ALTERNATIVESHOWNAMEMAPPING, \ MOVIENAMEMAPPING, ALTERNATIVEMOVIENAMEMAPPING, \ SKIPSHOW, SKIPMOVIE, \ NOTIFY, NOTIFYMAIL, MAILSRV, MAILFROMADDR, MAILTOADDR, MAILUSERNAME, MAILPASSWORD, MAILSUBJECT, MAILAUTH, \ MAILENCRYPTION, NOTIFYTWITTER, TWITTERKEY, TWITTERSECRET, NOTIFYPUSHALOT, PUSHALOTAPI, \ NOTIFYPUSHOVER, PUSHOVERKEY, PUSHOVERAPI, PUSHOVERDEVICES, \ NOTIFYGROWL, GROWLHOST, GROWLPORT, GROWLPASS, GROWLPRIORITY, NOTIFYPROWL, PROWLAPI, PROWLPRIORITY, \ NOTIFYPUSHBULLET, PUSHBULLETAPI, NOTIFYTELEGRAM, TELEGRAMBOTAPI, TELEGRAMCHATID, \ POSTPROCESS, POSTPROCESSINDIVIDUAL, POSTPROCESSUTF8ENCODING, SHOWPOSTPROCESSCMD, SHOWPOSTPROCESSCMDARGS, \ MOVIEPOSTPROCESSCMD, MOVIEPOSTPROCESSCMDARGS # Fake some entry points to get libraries working without installation _fake_entry_points() # Check python version PYTHONVERSION = get_python_version_strict() python_version_changed = _check_python_version_change() # System settings PATH = os.path.abspath(getcwd()) CACHEDIR = os.path.abspath(os.path.join(PATH, 'cache')) DEREFERURL = 'http://www.dereferer.org/?' GITHUBURL = 'https://github.com/h3llrais3r/Auto-Subliminal' VERSIONURL = 'https://raw.github.com/h3llrais3r/Auto-Subliminal/master/autosubliminal/version.py' USERAGENT = 'Auto-Subliminal/' + version.RELEASE_VERSION TIMEOUT = 300 # Wanted queue settings WANTEDQUEUE = [] WANTEDQUEUELOCK = False # Websocket settings WEBSOCKETMESSAGEQUEUE = [] # Scheduler settings SCHEDULERS = {} # Developer settings DEVELOPER = False # Indexer settings TVDBAPIKEY = '76F2D5362F45C5EC' TVDBURL = 'http://thetvdb.com/?tab=series&id=' IMDBURL = 'http://www.imdb.com/title/' SHOWINDEXER = ShowIndexer() MOVIEINDEXER = MovieIndexer() # Startup settings STARTED = False UUID = uuid.uuid4( ) # Generate random uuid each time we initialize the application # Webserver settings LAUNCHBROWSER = True # Score settings SHOWMINMATCHSCOREDEFAULT = 330 MOVIEMINMATCHSCOREDEFAULT = 90 # Cache settings _init_cache(python_version_changed) # Guessit settings _init_guessit() # Subliminal settings SUBLIMINALPROVIDERMANAGER = _init_subliminal(python_version_changed) SUBLIMINALPROVIDERCONFIGS = {} # Langdetect settings _init_langdetect() # Config settings CONFIGUPGRADED = False if CONFIGFILE is None: CONFIGFILE = 'config.properties' config.read_config(True) if CONFIGUPGRADED: print('INFO: Config seems to be upgraded. Writing config.') config.write_config() print('INFO: Writing config done.') # Change to the new work directory if os.path.exists(PATH): os.chdir(PATH) else: print('ERROR: PATH does not exist, check config.') os._exit(1) # Database settings DBFILE = 'database.db' DBTIMESTAMPFORMAT = '%Y-%m-%d %H:%M:%S' db.initialize() # Logging settings logger.initialize()