def old_assume_quality(guessed_quality: Quality, assumed_quality: Quality) -> Quality: if assumed_quality: if not guessed_quality: return assumed_quality if assumed_quality.resolution: guessed_quality.resolution = assumed_quality.resolution if assumed_quality.source: guessed_quality.source = assumed_quality.source if assumed_quality.codec: guessed_quality.codec = assumed_quality.codec if assumed_quality.audio: guessed_quality.audio = assumed_quality.audio return guessed_quality
def __init__( self, data: str = None, name: str = None, identified_by: str = None, id_type: str = None, id: Union[Tuple[int, int], str, int, datetime.date] = None, episodes: int = 1, season_pack: bool = False, strict_name: bool = False, quality: Quality = None, proper_count: int = 0, special: bool = False, group: Optional[str] = None, valid: bool = True, ) -> None: self.name: str = name self.data: str = data self.episodes: int = episodes self.season_pack: bool = season_pack self.identified_by: str = identified_by self.id: Union[Tuple[int, int], str, int, datetime.date] = id self.id_type: str = id_type self.quality: Quality = quality if quality is not None else Quality() self.proper_count: int = proper_count self.special: bool = special self.group: Optional[str] = group self.valid: bool = valid self.strict_name: bool = strict_name
def __init__( self, data=None, name=None, identified_by=None, id_type=None, id=None, episodes=1, season_pack=False, strict_name=False, quality=None, proper_count=0, special=False, group=None, valid=True, ): self.name = name self.data = data self.episodes = episodes self.season_pack = season_pack self.identified_by = identified_by self.id = id self.id_type = id_type self.quality = quality if quality is not None else Quality() self.proper_count = proper_count self.special = special self.group = group self.valid = valid self.strict_name = strict_name
def __init__(self, data=None, name=None, year=None, quality=None, proper_count=0, release_group=None, valid=True): self.name = name self.data = data self.year = year self.quality = quality if quality is not None else Quality() self.proper_count = proper_count self.release_group = release_group self.valid = valid
def _get_lower_limit(value): min_value = 0 if isinstance(value, Quality): min_value = Quality() elif isinstance(value, bool): min_value = False elif isinstance(value, datetime): min_value = datetime.now() # assume date comparision vs now() elif isinstance(value, timedelta): min_value = timedelta(0) return min_value
def test_qualities(self): items = [ ('Test.File 1080p.web-dl', '1080p webdl'), ('Test.File.web-dl.1080p', '1080p webdl'), ('Test.File.720p.bluray', '720p bluray'), ('Test.File.1080p.bluray', '1080p bluray'), ('Test.File.1080p.cam', '1080p cam'), ('A Movie 2011 TS 576P XviD-DTRG', '576p ts xvid'), ('Test.File.720p.bluray.r5', '720p r5'), ('Test.File.1080p.bluray.rc', '1080p r5'), # 10bit ('Test.File.480p.10bit', '480p 10bit'), ('Test.File.720p.10bit', '720p 10bit'), ('Test.File.720p.bluray.10bit', '720p bluray 10bit'), ('Test.File.1080p.10bit', '1080p 10bit'), ('Test.File.1080p.bluray.10bit', '1080p bluray 10bit'), ('Test.File.720p.webdl', '720p webdl'), ('Test.File.1280x720_web dl', '720p webdl'), ('Test.File.720p.h264.web.dl', '720p webdl h264'), ('Test.File.1080p.web.x264', '1080p webdl h264'), ('Test.File.web-dl', 'webdl'), ('Test.File.720P', '720p'), ('Test.File.1920x1080', '1080p'), ('Test.File.1080i', '1080i'), ('Test File blurayrip', 'bluray'), ('Test.File.br-rip', 'bluray'), ('Test.File.720px', '720p'), ('Test.File.dvd.rip', 'dvdrip'), ('Test.File.dvd.rip.r5', 'r5'), ('Test.File.[576p][00112233].mkv', '576p'), ('Test.TS.FooBar', 'ts'), ('Test.File.360p.avi', '360p'), ('Test.File.[360p].mkv', '360p'), ('Test.File.368.avi', '368p'), ('Test.File.720p.hdtv.avi', '720p hdtv'), ('Test.File.1080p.hdtv.avi', '1080p hdtv'), ('Test.File.720p.preair.avi', '720p preair'), ('Test.File.ts.dvdrip.avi', 'ts'), ('Test.File.HDTS.blah', 'ts'), ('Test.File.HDCAM.bluray.lie', 'cam'), # Test qualities as part of words. #1593 ('Tsar.File.720p', '720p'), ('Camera.1080p', '1080p') ] for item in items: quality = Quality(item[0]).name assert quality == item[ 1], '`%s` quality should be `%s` not `%s`' % (item[0], item[1], quality)
def search(self, task, entry, config=None): entries = set() search_strings = [ normalize_unicode(s) for s in entry.get('search_strings', [entry['title']]) ] for search_string in search_strings: url = 'https://yts.am/api/v2/list_movies.json?query_term=%s' % ( quote(search_string.encode('utf-8')) ) logger.debug('requesting: {}', url) try: result = requests.get(url) try: data = result.json() except ValueError: logger.debug('Could not decode json from response: {}', result.text) raise plugin.PluginError('Error getting result from yts.') except requests.RequestException as e: raise plugin.PluginError('Could not retrieve query from yts (%s)' % e.args[0]) if not data['status'] == 'ok': raise plugin.PluginError('failed to query YTS') try: if data['data']['movie_count'] > 0: for item in data['data']['movies']: for torrent in item['torrents']: entry = Entry() entry['title'] = item['title_long'] entry['year'] = item['year'] entry['url'] = torrent['url'] entry['content_size'] = parse_filesize( str(torrent['size_bytes']) + "b" ) entry['torrent_seeds'] = torrent['seeds'] entry['torrent_leeches'] = torrent['peers'] entry['torrent_info_hash'] = torrent['hash'] entry['torrent_availability'] = torrent_availability( entry['torrent_seeds'], entry['torrent_leeches'] ) entry['quality'] = Quality(f"{torrent['quality']} {torrent['type']}") entry['movie_name'] = item['title'] entry['movie_year'] = item['year'] entry['imdb_id'] = item['imdb_code'] if entry.isvalid(): entries.add(entry) except Exception: logger.debug('invalid return structure from YTS') logger.debug('Search got {} results', len(entries)) return entries
def __init__( self, data: str = None, name: str = None, year: Optional[int] = None, quality: Quality = None, proper_count: int = 0, release_group: Optional[str] = None, valid: bool = True, ) -> None: self.name: str = name self.data: str = data self.year: Optional[int] = year self.quality: Quality = quality if quality is not None else Quality() self.proper_count: int = proper_count self.release_group: Optional[str] = release_group self.valid: bool = valid
def test_common_name(self): for test_val in ('720p', '1280x720'): got_val = Quality(test_val).name assert got_val == '720p', got_val
def test_get(self): assert not Quality(), 'unknown quality is not false' assert Quality('foobar') == Quality(), 'unknown not returned'