Exemplo n.º 1
0
def test_get_tvdb_id_from_cache_not_found(monkeypatch, mocker):
    monkeypatch.setattr('autosubliminal.SHOWNAMEMAPPING', {})
    mocker.patch('autosubliminal.db.TvdbIdCacheDb.get_tvdb_id',
                 return_value=TVDB_ID_UNKNOWN)
    indexer = ShowIndexer()
    assert indexer.get_tvdb_id(
        u'The Big Bang Theory', force_search=False, store_id=False) is None
Exemplo n.º 2
0
def test_get_tvdb_id_from_show_name_mapping(monkeypatch):
    monkeypatch.setattr('autosubliminal.SHOWNAMEMAPPING',
                        {'the big bang theory': 80379})
    indexer = ShowIndexer()
    assert indexer.get_tvdb_id(u'The Big Bang Theory',
                               force_search=False,
                               store_id=False) == 80379
Exemplo n.º 3
0
def test_get_tvdb_id_exception(mocker):
    mocker.patch('autosubliminal.indexer.ShowIndexer._search', side_effect=Exception)
    db_mock_delete = mocker.patch('autosubliminal.db.TvdbIdCacheDb.delete_tvdb_id')
    db_mock_set = mocker.patch('autosubliminal.db.TvdbIdCacheDb.set_tvdb_id')
    indexer = ShowIndexer()
    assert indexer.get_tvdb_id(u'The Big Bang Theory', force_search=True, store_id=True) is None
    assert db_mock_delete.called
    assert db_mock_set.called
Exemplo n.º 4
0
def test_get_show_episode():
    indexer = ShowIndexer()
    episode = indexer.get_show_episode(80379, 1, 1)
    assert isinstance(episode, ShowEpisodeDetails)
    assert episode.tvdb_id == 332484
    assert episode.show_tvdb_id == '80379'
    assert episode.title == 'Pilot'
    assert episode.season == 1
    assert episode.episode == 1
Exemplo n.º 5
0
def test_get_show_episode():
    indexer = ShowIndexer()
    episode = indexer.get_show_episode(80379, 1, 1)
    assert isinstance(episode, ShowEpisodeDetails)
    assert episode.tvdb_id == 332484
    assert episode.show_tvdb_id == '80379'
    assert episode.title == 'Pilot'
    assert episode.season == 1
    assert episode.episode == 1
Exemplo n.º 6
0
def test_get_tvdb_id_and_store_in_cache(mocker):
    search_result = SeriesSearchResult(id=80379)
    mocker.patch('autosubliminal.indexer.ShowIndexer._search', return_value=search_result)
    db_mock_delete = mocker.patch('autosubliminal.db.TvdbIdCacheDb.delete_tvdb_id')
    db_mock_set = mocker.patch('autosubliminal.db.TvdbIdCacheDb.set_tvdb_id')
    indexer = ShowIndexer()
    assert indexer.get_tvdb_id(u'The Big Bang Theory', force_search=True, store_id=True) == 80379
    assert db_mock_delete.called
    assert db_mock_set.called
Exemplo n.º 7
0
 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()
Exemplo n.º 8
0
def test_get_show_details():
    indexer = ShowIndexer()
    show_details = indexer.get_show_details(80379)
    assert show_details is not None
    assert isinstance(show_details, ShowDetails)
    assert show_details.tvdb_id == 80379
    assert show_details.title == 'The Big Bang Theory'
    assert show_details.year == 2007
    assert show_details.overview is not None
    assert show_details.banner is not None
    assert show_details.poster is not None
Exemplo n.º 9
0
def test_get_show_details():
    indexer = ShowIndexer()
    show_details = indexer.get_show_details(80379)
    assert show_details is not None
    assert isinstance(show_details, ShowDetails)
    assert show_details.tvdb_id == 80379
    assert show_details.title == 'The Big Bang Theory'
    assert show_details.year == 2007
    assert show_details.overview is not None
    assert show_details.banner is not None
    assert show_details.poster is not None
Exemplo n.º 10
0
def test_get_tvdb_id_exception(mocker):
    mocker.patch('autosubliminal.indexer.ShowIndexer._search',
                 side_effect=Exception)
    db_mock_delete = mocker.patch(
        'autosubliminal.db.TvdbIdCacheDb.delete_tvdb_id')
    db_mock_set = mocker.patch('autosubliminal.db.TvdbIdCacheDb.set_tvdb_id')
    indexer = ShowIndexer()
    assert indexer.get_tvdb_id(
        u'The Big Bang Theory', force_search=True, store_id=True) is None
    assert db_mock_delete.called
    assert db_mock_set.called
Exemplo n.º 11
0
def test_get_tvdb_id_and_store_in_cache(mocker):
    search_result = SeriesSearchResult(id=80379)
    mocker.patch('autosubliminal.indexer.ShowIndexer._search',
                 return_value=search_result)
    db_mock_delete = mocker.patch(
        'autosubliminal.db.TvdbIdCacheDb.delete_tvdb_id')
    db_mock_set = mocker.patch('autosubliminal.db.TvdbIdCacheDb.set_tvdb_id')
    indexer = ShowIndexer()
    assert indexer.get_tvdb_id(u'The Big Bang Theory',
                               force_search=True,
                               store_id=True) == 80379
    assert db_mock_delete.called
    assert db_mock_set.called
Exemplo n.º 12
0
def test_get_show_episodes():
    indexer = ShowIndexer()
    episodes = indexer.get_show_episodes(80379)
    assert episodes is not None
    assert isinstance(episodes, list)
    assert len(episodes) > 0
    episode = episodes[0]
    assert isinstance(episode, ShowEpisodeDetails)
    assert episode.tvdb_id == 332484
    assert episode.show_tvdb_id == '80379'
    assert episode.title == 'Pilot'
    assert episode.season == 1
    assert episode.episode == 1
Exemplo n.º 13
0
def test_get_show_episodes():
    indexer = ShowIndexer()
    episodes = indexer.get_show_episodes(80379)
    assert episodes is not None
    assert isinstance(episodes, list)
    assert len(episodes) > 0
    episode = episodes[0]
    assert isinstance(episode, ShowEpisodeDetails)
    assert episode.tvdb_id == 332484
    assert episode.show_tvdb_id == '80379'
    assert episode.title == 'Pilot'
    assert episode.season == 1
    assert episode.episode == 1
Exemplo n.º 14
0
def test_get_tvdb_id():
    indexer = ShowIndexer()
    # By name
    assert indexer.get_tvdb_id(u'The Big Bang Theory', force_search=True, store_id=False) == 80379
    assert indexer.get_tvdb_id(u'Mr Robot', force_search=True, store_id=False) == 289590
    # By alias
    assert indexer.get_tvdb_id(u'Big Bang', force_search=True, store_id=False) == 80379
    # By name and year
    assert indexer.get_tvdb_id(u'The Americans', year=2013, force_search=True, store_id=False) == 261690
    # By name and language
    assert indexer.get_tvdb_id(u'Fais pas ci, fais pas ça', language='fr', force_search=True, store_id=False) == 80977
Exemplo n.º 15
0
def test_get_tvdb_id():
    indexer = ShowIndexer()
    assert indexer.get_tvdb_id(u'The Big Bang Theory',
                               force_search=True,
                               store_id=False) == 80379
    assert indexer.get_tvdb_id(u'The Americans',
                               year=2013,
                               force_search=True,
                               store_id=False) == 261690
    assert indexer.get_tvdb_id(u'Mr Robot', force_search=True,
                               store_id=False) == 289590
    assert indexer.get_tvdb_id(u'Fais pas ci, fais pas ça',
                               language='fr',
                               force_search=True,
                               store_id=False) == 80977
Exemplo n.º 16
0
def test_get_tvdb_id_from_show_name_mapping(monkeypatch):
    monkeypatch.setattr('autosubliminal.SHOWNAMEMAPPING', {'the big bang theory': 80379})
    indexer = ShowIndexer()
    assert indexer.get_tvdb_id(u'The Big Bang Theory', force_search=False, store_id=False) == 80379
Exemplo n.º 17
0
class LibraryPathScanner(object):
    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 scan_path(self, path):
        log.info('Scanning path: %s', path)

        # Check all folders and files
        for dirname, dirnames, filenames in os.walk(os.path.join(path)):
            log.debug('Directory: %s', dirname)

            # Ignore skipped dirs
            if is_skipped_dir(dirname):
                continue

            # Check files
            for filename in filenames:
                # Only scan valid video files
                if is_valid_video_file(filename, video_extensions=EXTENDED_VIDEO_EXTENSIONS):
                    log.debug('Video file found: %s', filename)
                    try:
                        self._scan_file(dirname, filename)
                    except Exception:
                        log.exception('Error while scanning video file: %s', os.path.join(dirname, filename))

    def _scan_file(self, dirname, filename):
        wanted_item = process_file(dirname, filename)
        if wanted_item:
            if wanted_item.is_episode:
                # Do a force search if no tvdb id found
                if not wanted_item.tvdbid:
                    wanted_item.tvdbid = self.show_indexer.get_tvdb_id(wanted_item.title, year=wanted_item.year,
                                                                       force_search=True)

                # Skip if no tvdb id is found
                if not wanted_item.tvdbid:
                    log.warning('Skipping show episode file with unknown tvdb id: %s', os.path.join(dirname, filename))
                    show_path = self._get_show_path(dirname)
                    if not self.failed_shows_db.get_failed_show(show_path):
                        self.failed_shows_db.set_failed_show(show_path)
                    return

                # Store default show settings if not yet available
                if not self.show_settings_db.get_show_settings(wanted_item.tvdbid):
                    self.show_settings_db.set_show_settings(ShowSettings.default_settings(wanted_item.tvdbid))
                show_settings = self.show_settings_db.get_show_settings(wanted_item.tvdbid)

                # Get show details
                show_details = self.show_db.get_show(wanted_item.tvdbid)
                # Add show and episodes to db if not yet in db
                if not show_details:
                    show_details = self.show_indexer.get_show_details(wanted_item.tvdbid)
                    if show_details:
                        show_details.path = self._get_show_path(dirname)
                        self.show_db.set_show(show_details)
                        episodes = self.show_indexer.get_show_episodes(wanted_item.tvdbid)
                        if episodes:
                            for episode in episodes:
                                self.show_episodes_db.set_show_episode(episode)

                # Cache artwork (fullsize and thumbnail) if not yet cached
                if show_details:
                    # Poster
                    if show_details.poster:
                        if not is_artwork_cached(self.show_indexer.name, show_details.tvdb_id, 'poster'):
                            cache_artwork(self.show_indexer.name, show_details.tvdb_id, 'poster',
                                          get_artwork_url(show_details.poster))
                        if not is_artwork_cached(self.show_indexer.name, show_details.tvdb_id, 'poster',
                                                 thumbnail=True):
                            cache_artwork(self.show_indexer.name, show_details.tvdb_id, 'poster',
                                          get_artwork_url(show_details.poster, thumbnail=True), thumbnail=True)
                    # Banner
                    if show_details.banner:
                        if not is_artwork_cached(self.show_indexer.name, show_details.tvdb_id, 'banner'):
                            cache_artwork(self.show_indexer.name, show_details.tvdb_id, 'banner',
                                          get_artwork_url(show_details.banner))
                        if not is_artwork_cached(self.show_indexer.name, show_details.tvdb_id, 'banner',
                                                 thumbnail=True):
                            cache_artwork(self.show_indexer.name, show_details.tvdb_id, 'banner',
                                          get_artwork_url(show_details.banner, thumbnail=True), thumbnail=True)

                # Check episode details
                if isinstance(wanted_item.episode, list):
                    for episode in wanted_item.episode:
                        self._update_episode_details(show_settings, dirname, filename, wanted_item.tvdbid,
                                                     wanted_item.season, episode)
                else:
                    self._update_episode_details(show_settings, dirname, filename, wanted_item.tvdbid,
                                                 wanted_item.season, wanted_item.episode)
            if wanted_item.is_movie:
                # Do a force search if no imdb id found
                if not wanted_item.imdbid:
                    wanted_item.imdbid, _ = self.movie_indexer.get_imdb_id_and_year(wanted_item.title,
                                                                                    year=wanted_item.year,
                                                                                    force_search=True)

                # Skip if no imdb id is found
                if not wanted_item.imdbid:
                    log.warning('Skipping movie file with unknown imdb id: %s', os.path.join(dirname, filename))
                    if not self.failed_movies_db.get_failed_movie(dirname):
                        self.failed_movies_db.set_failed_movie(dirname)
                    return

                # Store default movie settings if not yet available
                if not self.movie_settings_db.get_movie_settings(wanted_item.imdbid):
                    self.movie_settings_db.set_movie_settings(MovieSettings.default_settings(wanted_item.imdbid))
                movie_settings = self.movie_settings_db.get_movie_settings(wanted_item.imdbid)

                # Get movie details
                movie_details = self.movie_db.get_movie(wanted_item.imdbid)
                # Add movie to db if not yet in db
                if not movie_details:
                    movie_details = self.movie_indexer.get_movie_details(wanted_item.imdbid)
                    if movie_details:
                        movie_details.path = dirname
                        self.movie_db.set_movie(movie_details)

                # Cache artwork (fullsize and thumbnail) if not yet cached
                if movie_details:
                    # Poster
                    if movie_details.poster:
                        if not is_artwork_cached(self.movie_indexer.name, movie_details.imdb_id, 'poster'):
                            cache_artwork(self.movie_indexer.name, movie_details.imdb_id, 'poster',
                                          movie_details.poster)
                        if not is_artwork_cached(self.movie_indexer.name, movie_details.imdb_id, 'poster',
                                                 thumbnail=True):
                            cache_artwork(self.movie_indexer.name, movie_details.imdb_id, 'poster',
                                          self.movie_indexer.get_artwork_thumbnail_url(movie_details.poster),
                                          thumbnail=True)

                # Check movie details
                self._update_movie_details(movie_settings, dirname, filename, wanted_item.imdbid)

    def _get_show_path(self, dirname):
        path = dirname
        # Get root show path (ignore season folders)
        while 'season' in safe_lowercase(os.path.normpath(os.path.normcase(path))):
            path, _ = os.path.split(path)
        return path

    def _update_episode_details(self, show_settings, dirname, filename, show_tvdb_id, season, episode):
        episode_details = self.show_episodes_db.get_show_episode(show_tvdb_id, season, episode)

        # If no episode is found, we need to fetch the episode details of the show
        # This is because the show is still on-going and we didn't got all episodes when the show was loaded
        if not episode_details:
            episode_details = self.show_indexer.get_show_episode(show_tvdb_id, season, episode)
            if episode_details:
                self.show_episodes_db.set_show_episode(episode_details)

        if episode_details:
            # Set details
            available_subtitles = get_available_subtitles(dirname, filename, autosubliminal.SCANEMBEDDEDSUBS,
                                                          autosubliminal.SCANHARDCODEDSUBS)
            missing_languages = self._get_missing_subtitle_languages(available_subtitles,
                                                                     wanted_languages=show_settings.wanted_languages)
            episode_details.subtitles = available_subtitles
            episode_details.missing_languages = missing_languages
            episode_details.path = os.path.abspath(os.path.join(dirname, filename))
            # Update details in db
            self.show_episodes_db.update_show_episode(episode_details, subtitles=True)

    def _update_movie_details(self, movie_settings, dirname, filename, imdb_id):
        movie_details = self.movie_db.get_movie(imdb_id)

        if movie_details:
            # Set details
            available_subtitles = get_available_subtitles(dirname, filename, autosubliminal.SCANEMBEDDEDSUBS,
                                                          autosubliminal.SCANHARDCODEDSUBS)
            missing_languages = self._get_missing_subtitle_languages(available_subtitles,
                                                                     wanted_languages=movie_settings.wanted_languages)
            movie_details.subtitles = available_subtitles
            movie_details.missing_languages = missing_languages
            movie_details.path = os.path.abspath(os.path.join(dirname, filename))
            # Update details in db
            self.movie_db.update_movie(movie_details, subtitles=True)

    def _get_missing_subtitle_languages(self, available_subtitles, wanted_languages=None):
        # Use custom wanted languages or globally configured wanted languages if not provided
        if wanted_languages is None:
            wanted_languages = get_wanted_languages()

        available_languages = []
        for subtitle in available_subtitles:
            available_languages.append(subtitle.language)

        # Return the missing languages (= not in available languages)
        return [language for language in wanted_languages if language not in available_languages]
Exemplo n.º 18
0
# 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')
Exemplo n.º 19
0
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()
Exemplo n.º 20
0
def test_get_tvdb_id_from_cache_not_found(monkeypatch, mocker):
    monkeypatch.setattr('autosubliminal.SHOWNAMEMAPPING', {})
    mocker.patch('autosubliminal.db.TvdbIdCacheDb.get_tvdb_id', return_value=TVDB_ID_UNKNOWN)
    indexer = ShowIndexer()
    assert indexer.get_tvdb_id(u'The Big Bang Theory', force_search=False, store_id=False) is None