示例#1
0
    def __init__(self, *args, **kwargs):
        super(GuessVideo, self).__init__(*args, **kwargs)

        # Determine common attributes (extension, video parts):
        self.guess_common(pass_=1)

        # Determine video type (movie or episode):
        self.find_matches(self._mask, attributes=['video.episodes'], index=0)

        # Determine specific attributes based on identified type:
        if 'episodes' in self._matches:
            self['type'] = 'shows'
            self.guess_show(pass_=1)
            self.guess_common(pass_=2)
            self.guess_show(pass_=2)
        else:
            self['type'] = 'movies'
            self.guess_common(pass_=2)
            self.guess_movie(pass_=1)

        # Normalize guessed attributes:
        self.guess_common(pass_=3)

        # Correlate guessed results with web search:
        ## Check provider status:
        self.provider = providers.get('tmdb')
        if not self.provider:
            self._disable_webmatch = True

        ## Perform search:
        if not self._disable_webmatch:
            # Web search is allowed only for files or release directories:
            if ((self.is_file and 'title' in self._matches) or (not self.is_file and 'group' in self._matches)):
                results = self.search_web()
                # If match found, update data:
                if results:
                    self._webmatched = True
                    for k in ['type', 'title', 'original_title', 'year', 'release_date', 'release_country','tmdb_id']:
                        self[k] = results[0].get(k)

        # Perform additional processing when analyzed string is a file and displays a parent directory:
        if self.is_file and self.parent_dir:
            if not self._webmatched or (self._webmatched and 'group' in self._matches):
                # @TODO: If episode, check parent directories to identify title/season information (e.g. "Title (Year)/Season XX patterns.
                # Otherwise, go back through parent direcoties in search of a release pattern:
                parent_dir = self.parent_dir
                while parent_dir:
                    # Check all parent directories' name until there root or a match has been found:
                    guess_parent = GuessVideo(parent_dir, disable_webmatch=self._disable_webmatch)
                    if guess_parent._webmatched and 'group' in guess_parent._matches:
                        self._webmatched = True
                        self._parent = guess_parent
                        self.update(guess_parent)
                        break
                    parent_dir = guess_parent.parent_dir

            if self.is_in_season_dir:
                self['release'] = self.parent['release'].replace(self.parent._matches['episodes'][0].group(), self._matches['episodes'][0].group())
 def test_raw_search_movie_with_year(self):
     p = providers.get(self.name)
     results = p.raw_query(type='movie', title='Casino Royale', year=2006)
     assert len(results) > 0
     assert all([re.search(r'casino[\.\s_]royale[\.\s_\-\[]', x['description'], flags=re.I) is not None for x in results])
     assert all([re.search(r'[\.\s_\-\[]1966[\.\s_\-\]]', x['description'], flags=re.I) is None for x in results])
 def test_init(self):
     p = providers.get(self.name)
     assert p.name.lower() == self.name
 def test_raw_search_movie_with_imdb(self):
     p = providers.get(self.name)
     results = p.raw_query(type='movie', title='Casino Royale', imdb_id='tt0381061')
     assert len(results) > 0
     assert all([re.search(r'casino[\.\s_]royale[\.\s_\-\[]', x['description'], flags=re.I) is not None for x in results])
 def test_raw_search_show_with_episode_1(self):
     p = providers.get(self.name)
     results = p.raw_query(type='show', title='Mr. Robot', season=1, episode=2)
     assert len(results) > 0
     assert all([re.search(r'Mr[\.\s_]Robot[\.\s_\-]', x['description'], flags=re.I) is not None for x in results])
     assert all([re.search(r'[\.\s_]S01E02[\.\s_\-]', x['description'], flags=re.I) is not None for x in results])
 def test_raw_search_show_with_episode_2(self):
     p = providers.get(self.name)
     results = p.raw_query(type='show', title='Marvel\'s Agents of S.H.I.E.L.D.', season=2, episode=4)
     assert len(results) > 0
     assert all([re.search(r'Marvels[\.\s_]Agents[\.\s_]of[\.\s_]S[\.\s_]H[\.\s_]I[\.\s_]E[\.\s_\-]L[\.\s_]D', x['description'], flags=re.I) is not None for x in results])
     assert all([re.search(r'[\.\s_]S02E04[\.\s_\-]', x['description'], flags=re.I) is not None for x in results])
 def test_raw_search_show(self):
     p = providers.get(self.name)
     results = p.raw_query(type='show', title='Mr. Robot')
     assert len(results) > 0
     assert all([re.search(r'Mr[\.\s_]Robot[\.\s_\-]', x['description'], flags=re.I) is not None for x in results])
 def test_raw_search_show_with_year_2(self):
     p = providers.get(self.name)
     results = p.raw_query(type='show', title='House of Cards (2013)', year=2013)
     assert len(results) > 0
     assert all([re.search(r'House[\.\s_]of[\.\s_]Cards[\.\s_]2013[\.\s_\-]', x['description'], flags=re.I) is not None for x in results])
 def test_google_translate_detect_language(self):
     p = providers.get(self.name)
     assert 'fr' == p.detect_language('La vie est belle !!!')
def test_discard():
    providers.discard('nzbget')
    p = providers.get('nzbget')
    assert p is None
    p = providers.gets(capability='downloader')
    assert 'nzbget' not in [i.name.lower() for i in p]
def test_get_with_settings():
    p = providers.get('nzbget', settings={'host':'192.168.1.8'})
    assert p.name.lower() == 'nzbget'
    assert p.settings['host'] == '192.168.1.8'
    assert providers.settings['nzbget']['host'] == '192.168.1.8'
def test_get():
    p = providers.get('nzbget')
    assert 'nzbget' in providers.initialized
    assert p.name.lower() == 'nzbget'
    assert p.settings['host'] == '192.168.1.4'
示例#13
0
import logging
import os
import babelfish
from time import time, sleep
from datetime import datetime
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('dogpile').setLevel(logging.ERROR)
from unittest.mock import Mock
providers.register(providers_settings={
    'nzbget': {'host':'192.168.1.4'},
    'transmission': {'host':'192.168.1.4'},
    'nzbsorg': {'api_key': '585bc38cf88ca81dbd5f779e396a20a6'},
    'addic7ed': {'username': '******', 'password': '******'},

}, cache_settings={'path': 'cache/cachefile.dbm'})
p = providers.get('nzbget', settings={'host':'192.168.1.8'})

qualities = [
    # SHOWS:
    {'type':'shows', 'label':'1080p', 'priority':1, 'include_all': ['1080[pi]'], 'include_any': [], 'exclude_any':['german','nl(subs)?','ita','jpn','swesub','nordic\.subpack','\d{3}MB'], 'exclude_all': [], 'include_bonus': '(HDTV),(web\-dl,webrip)', 'exclude_bonus': '(DD\.?5\.1),(french,AAC)'},
    {'type':'shows', 'label':'720p' , 'priority':2, 'include_all': ['720p'],     'include_any': [], 'exclude_any':['german','nl(subs)?','ita','jpn','swesub','nordic\.subpack','\d{3}MB'], 'exclude_all': [], 'include_bonus': '(HDTV),(web\-dl,webrip)', 'exclude_bonus': '(DD\.?5\.1),(french,AAC)'},
    {'type':'shows', 'label':'SD'   , 'priority':3, 'include_all': ['HDTV'],     'include_any': [], 'exclude_any':['720p', '1080[pi]','german','nl(subs)?','ita','jpn','swesub','nordic\.subpack','\d{3}MB'], 'exclude_all': [], 'include_bonus': '', 'exclude_bonus': '(french,AAC)'},
    # MOVIES:
    {'type':'movies', 'label':'1080p', 'priority':1, 'include_all': ['1080[pi]'], 'include_any': [], 'exclude_any':['german','nl(subs)?','ita','jpn','swesub','nordic\.subpack','\d{3}MB'], 'exclude_all': [], 'include_bonus': '(Blu-?Ray)', 'exclude_bonus': '(french,AAC)'},
    {'type':'movies', 'label':'720p' , 'priority':2, 'include_all': ['720p'],     'include_any': [], 'exclude_any':['german','nl(subs)?','ita','jpn','swesub','nordic\.subpack','\d{3}MB'], 'exclude_all': [], 'include_bonus': '(Blu-?Ray)', 'exclude_bonus': '(french,AAC)'},
    {'type':'movies', 'label':'SD'   , 'priority':3, 'include_all': [],           'include_any': [], 'exclude_any':['720p', '1080[pi]','german','nl(subs)?','ita','jpn','swesub','nordic\.subpack','\d{3}MB'], 'exclude_all': [], 'include_bonus': '', 'exclude_bonus': '(french,AAC)'},
]
# VIDEOS:
title_movie   = Mock(**{'type': 'movies', 'title': 'American Sniper', 'release_date.year': 2014, 'imdb_id': None})
title_episode = Mock(**{'type': 'episodes', 'show.title': 'Suits', 'show.release_date.year': None, 'show.release_country': 'US', 'season': 5, 'episode': 7, 'path':'Suits.S05E07.720p.HDTV.x264-KILLERS.mkv', 'source': 'HDTV', 'group':'KILLERS', 'filename':'Suits.S05E06.720p.HDTV.x264-KILLERS'})
video_episode = Mock(**{'type': 'episodes', 'title': 'Suits', 'year': None, 'release_country': 'US', 'season': 5, 'episode': 6, 'path':'Suits.S05E06.720p.HDTV.x264-KILLERS.mkv', 'source': 'HDTV', 'group':'KILLERS', 'filename':'Suits.S05E06.720p.HDTV.x264-KILLERS', 'imdb_id': None})