def __init__(self, parser, info, torr_path, episode): self._dict = dict(parser.Dict()) parts = [] parts.append('AVC/H.264') if info['quality'].lower() == 'sd': parts.append('720x540') elif info['quality'].lower() == 'hd': parts.append('1280x720') elif info['quality'].lower() == 'fullhd': parts.append('1920x1080') from base import TorrentPlayer player = TorrentPlayer() player.AddTorrent(torr_path) data = player.GetLastTorrentData() if data: add_dict = self.get_add_data(data) if episode: seconds = int(parser.episode_runtime) * 60 bitrate = add_dict['size'] * 8 / seconds parts.append(str(bitrate / 1000) + ' kbs') if parts: self._dict['video'] = ', '.join(parts)
def info_hash(self): if not self._info_hash and self.is_finished(): from base import TorrentPlayer tp = TorrentPlayer() tp.AddTorrent(self.saved_to) return tp.info_hash return self._info_hash
def get_relative_torrent_files_list(self): from base import TorrentPlayer tp = TorrentPlayer() tp.AddTorrent(self.torrent) data = tp.GetLastTorrentData() files = data['files'] return [filesystem.join(data['name'], item['name']) for item in files]
def AddTorrent(self, path): ''' Send a torrent to YATP usign add_torrent method. YATP accepts local and remote (http/https) paths to .torrent files and magnet links. Warning: paths on networked filesystems (smb/nfs) are not supported! ''' r = requests.post('http://localhost:8668/json-rpc', json={"method": "add_torrent", "params": {'torrent': path}}) debug(r.json()) TorrentPlayer.AddTorrent(self, path)
def scrape_nnm(): from player import load_settings settings = load_settings() data_path = settings.torrents_path() if not filesystem.exists(filesystem.join(data_path, 'nnmclub')): return hashes = [] for torr in filesystem.listdir(filesystem.join(data_path, 'nnmclub')): if torr.endswith('.torrent'): try: from base import TorrentPlayer tp = TorrentPlayer() tp.AddTorrent(filesystem.join(data_path, 'nnmclub', torr)) data = tp.GetLastTorrentData() if data: hashes.append((data['announce'], data['info_hash'], torr.replace('.torrent', '.stat'))) except BaseException as e: log.print_tb(e) for chunk in chunks(hashes, 32): import scraper try: seeds_peers = scraper.scrape(chunk[0][0], [i[1] for i in chunk], 10) except RuntimeError as RunE: if '414 status code returned' in RunE.message: for c in chunks(chunk, 16): try: seeds_peers = scraper.scrape(c[0][0], [i[1] for i in c], 10) process_chunk(c, data_path, seeds_peers) except BaseException as e: log.print_tb(e) continue except BaseException as e: log.print_tb(e) continue process_chunk(chunk, data_path, seeds_peers)
def all_torrent_files_exists(self): from base import TorrentPlayer tp = TorrentPlayer() tp.AddTorrent(self.torrent) data = tp.GetLastTorrentData() files = data['files'] for item in files: path = filesystem.join(self.storage_path, data['name'], item['name']) debug(u'all_torrent_files_exists: ' + path) if not filesystem.exists(path): path = filesystem.join(self.settings.copy_video_path, data['name'], item['name']) debug(u'all_torrent_files_exists: ' + path) if not filesystem.exists(path): debug(u'all_torrent_files_exists: not found') return False debug(u'all_torrent_files_exists: Ok') return True