def movie(movie_info): magnet_infos = [] try: json_data = network.json_get( YTS_URL + '/api/v2/list_movies.json', params={'query_term': movie_info['imdb_id']}) if 'data' in json_data: if 'movies' in json_data['data']: for movie_item in json_data['data']['movies']: if 'imdb_code' in movie_item and movie_item[ 'imdb_code'] == movie_info[ 'imdb_id'] and 'torrents' in movie_item: for torrent_item in movie_item['torrents']: magnet_title = u'{0} ({1}) {2} - YIFY'.format( movie_item['title'], movie_item['year'], torrent_item['quality']) magnet_url = u'magnet:?xt=urn:btih:{0}&dn={1}&tr=http://exodus.desync.com:6969/announce&tr=udp://tracker.openbittorrent.com:80/announce&tr=udp://open.demonii.com:1337/announce&tr=udp://exodus.desync.com:6969/announce&tr=udp://tracker.yify-torrents.com/announce'.format( torrent_item['hash'], urllib.quote(magnet_title.encode('utf8'))) magnet_infos.append( scraper.Magnet(magnet_url, magnet_title, torrent_item['seeds'], torrent_item['peers'], torrent_item['size_bytes'])) except requests.exceptions.HTTPError as exception: if exception.response.status_code in (404, 503): pass except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): pass except exceptions.JSONError: pass return magnet_infos
def episode(show_info, episode_info): magnet_infos = [] if show_info['imdb_id']: try: json_data = network.json_get(EZTV_URL + '/show/' + show_info['imdb_id']) if json_data and json_data['episodes']: for json_item in json_data['episodes']: if json_item['season'] == episode_info[ 'season_index'] and json_item[ 'episode'] == episode_info['episode_index']: for value in json_item['torrents'].values(): magnet_infos.append( scraper.Magnet(value['url'], None, value['seeds'], value['peers'], 0)) break except requests.exceptions.HTTPError as exception: if exception.response.status_code in (404, 503): pass except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): pass except exceptions.JSONError: pass return magnet_infos
def __shows_search(query, timeout=(network.TIMEOUT_CONNECT, network.TIMEOUT_READ)): json_data = network.json_get(TRAKT_URL + '/search', params={ 'query': query, 'type': 'show' }, headers=TRAKT_HEADERS, timeout=timeout) return __shows_list_parse(json_data)
def __shows_list_page(page, page_index, timeout=(network.TIMEOUT_CONNECT, network.TIMEOUT_READ)): json_data = network.json_get(TRAKT_URL + page, params={ 'page': page_index, 'limit': 31 }, headers=TRAKT_HEADERS, timeout=timeout) return __shows_list_parse(json_data)
def __show_seasons(trakt_slug, show_info, timeout=(network.TIMEOUT_CONNECT, network.TIMEOUT_READ)): result = [] json_data = network.json_get(TRAKT_URL + '/shows/' + trakt_slug + '/seasons', params={ 'extended': 'full,images' }, headers=TRAKT_HEADERS, timeout=timeout) for json_item in json_data: if json_item['number'] > 0: result.append({ 'show_title': show_info['title'], 'season_index': json_item['number'], 'title': 'Season {0}'.format(json_item['number']), 'overview': json_item['overview'], 'episode_count': json_item['episode_count'], 'thumb': json_item['images']['poster']['full'], 'art': show_info['art'] }) return result
def __show(trakt_slug, timeout=(network.TIMEOUT_CONNECT, network.TIMEOUT_READ)): json_data = network.json_get(TRAKT_URL + '/shows/' + trakt_slug, params={ 'extended': 'full,images' }, headers=TRAKT_HEADERS, timeout=timeout) return { 'trakt_slug': json_data['ids']['slug'], 'imdb_id': json_data['ids']['imdb'], 'title': json_data['title'], 'year': json_data['year'], 'overview': json_data['overview'], 'studio': json_data['network'], 'thumb': json_data['images']['poster']['full'], 'art': json_data['images']['fanart']['full'], 'runtime': (json_data['runtime'] * 60 * 1000) if json_data['runtime'] else 0, 'genres': [genre.capitalize() for genre in json_data['genres']], 'rating': json_data['rating'], 'first_aired': json_data['first_aired'], 'certification': json_data['certification'] }
def __show_season(trakt_slug, season_index, timeout=(network.TIMEOUT_CONNECT, network.TIMEOUT_READ)): show_info = show(trakt_slug) episode_infos = [] json_data = network.json_get(TRAKT_URL + '/shows/' + trakt_slug + '/seasons/' + str(season_index), params={ 'extended': 'full,images' }, headers=TRAKT_HEADERS, timeout=timeout) for json_item in json_data: if json_item['first_aired'] and datetime.datetime.now(dateutil.tz.tzutc()) > dateutil.parser.parse(json_item['first_aired']): episode_infos.append({ 'show_title': show_info['title'], 'season_index': json_item['season'], 'episode_index': json_item['number'], 'title': json_item['title'], 'thumb': json_item['images']['screenshot']['full'], 'art': json_item['images']['screenshot']['full'], 'overview': json_item['overview'], 'rating': json_item['rating'], 'first_aired': json_item['first_aired'], }) return episode_infos
def episode(show_info, episode_info): magnet_infos = [] if show_info['imdb_id']: try: json_data = network.json_get(EZTV_URL + '/show/' + show_info['imdb_id']) if json_data and json_data['episodes']: for json_item in json_data['episodes']: if json_item['season'] == episode_info['season_index'] and json_item['episode'] == episode_info['episode_index']: for value in json_item['torrents'].values(): magnet_infos.append(scraper.Magnet(value['url'], None, value['seeds'], value['peers'], 0)) break except requests.exceptions.HTTPError as exception: if exception.response.status_code in (404, 503): pass except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): pass except exceptions.JSONError: pass return magnet_infos
def movie(movie_info): magnet_infos = [] try: json_data = network.json_get(YTS_URL + '/api/v2/list_movies.json', params={ 'query_term': movie_info['imdb_id'] }) if 'data' in json_data: if 'movies' in json_data['data']: for movie_item in json_data['data']['movies']: if 'imdb_code' in movie_item and movie_item['imdb_code'] == movie_info['imdb_id'] and 'torrents' in movie_item: for torrent_item in movie_item['torrents']: magnet_title = u'{0} ({1}) {2} - YIFY'.format(movie_item['title'], movie_item['year'], torrent_item['quality']) magnet_url = u'magnet:?xt=urn:btih:{0}&dn={1}&tr=http://track.one:1234/announce&tr=udp://track.two:80&tr=udp://open.demonii.com:1337/announce&tr=udp://tracker.openbittorrent.com:80&tr=udp://tracker.coppersurfer.tk:6969&tr=udp://glotorrents.pw:6969/announce&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://torrent.gresille.org:80/announce&tr=udp://p4p.arenabg.com:1337&tr=udp://tracker.leechers-paradise.org:6969'.format(torrent_item['hash'], urllib.quote(magnet_title.encode('utf8'))) magnet_infos.append(scraper.Magnet(magnet_url, magnet_title, torrent_item['seeds'], torrent_item['peers'], torrent_item['size_bytes'])) except requests.exceptions.HTTPError as exception: if exception.response.status_code in (404, 503): pass except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): pass except exceptions.JSONError: pass return magnet_infos
def __show(trakt_slug, timeout=(network.TIMEOUT_CONNECT, network.TIMEOUT_READ)): json_data = network.json_get(TRAKT_URL + '/shows/' + trakt_slug, params={'extended': 'full,images'}, headers=TRAKT_HEADERS, timeout=timeout) return { 'trakt_slug': json_data['ids']['slug'], 'imdb_id': json_data['ids']['imdb'], 'title': json_data['title'], 'year': json_data['year'], 'overview': json_data['overview'], 'studio': json_data['network'], 'thumb': json_data['images']['poster']['full'], 'art': json_data['images']['fanart']['full'], 'runtime': (json_data['runtime'] * 60 * 1000) if json_data['runtime'] else 0, 'genres': [genre.capitalize() for genre in json_data['genres']], 'rating': json_data['rating'], 'first_aired': json_data['first_aired'], 'certification': json_data['certification'] }
def __movie_people(trakt_slug, timeout=(network.TIMEOUT_CONNECT, network.TIMEOUT_READ)): result = { 'cast': [], 'crew': { 'directing': [], 'production': [], 'writing': [] } } json_data = network.json_get(TRAKT_URL + '/movies/' + trakt_slug + '/people', params={ 'extended': 'images' }, headers=TRAKT_HEADERS, timeout=timeout) if 'cast' in json_data: for json_item in json_data['cast']: result['cast'].append({ 'name': json_item['person']['name'], 'headshot': json_item['person']['images']['headshot']['full'], 'character': json_item['character'] }) if 'crew' in json_data: if 'directing' in json_data['crew']: for json_item in json_data['crew']['directing']: result['crew']['directing'].append({ 'name': json_item['person']['name'], 'headshot': json_item['person']['images']['headshot']['full'], 'job': json_item['job'] }) if 'production' in json_data['crew']: for json_item in json_data['crew']['production']: result['crew']['production'].append({ 'name': json_item['person']['name'], 'headshot': json_item['person']['images']['headshot']['full'], 'job': json_item['job'] }) if 'writing' in json_data['crew']: for json_item in json_data['crew']['writing']: result['crew']['writing'].append({ 'name': json_item['person']['name'], 'headshot': json_item['person']['images']['headshot']['full'], 'job': json_item['job'] }) return result
def __show_seasons(trakt_slug, show_info, timeout=(network.TIMEOUT_CONNECT, network.TIMEOUT_READ)): result = [] json_data = network.json_get(TRAKT_URL + '/shows/' + trakt_slug + '/seasons', params={'extended': 'full,images'}, headers=TRAKT_HEADERS, timeout=timeout) for json_item in json_data: if json_item['number'] > 0: result.append({ 'show_title': show_info['title'], 'season_index': json_item['number'], 'title': 'Season {0}'.format(json_item['number']), 'overview': json_item['overview'], 'episode_count': json_item['episode_count'], 'thumb': json_item['images']['poster']['full'], 'art': show_info['art'] }) return result
def __show_season(trakt_slug, season_index, timeout=(network.TIMEOUT_CONNECT, network.TIMEOUT_READ)): show_info = show(trakt_slug) episode_infos = [] json_data = network.json_get(TRAKT_URL + '/shows/' + trakt_slug + '/seasons/' + str(season_index), params={'extended': 'full,images'}, headers=TRAKT_HEADERS, timeout=timeout) for json_item in json_data: if json_item['first_aired'] and datetime.datetime.now( dateutil.tz.tzutc()) > dateutil.parser.parse( json_item['first_aired']): episode_infos.append({ 'show_title': show_info['title'], 'season_index': json_item['season'], 'episode_index': json_item['number'], 'title': json_item['title'], 'thumb': json_item['images']['screenshot']['full'], 'art': json_item['images']['screenshot']['full'], 'overview': json_item['overview'], 'rating': json_item['rating'], 'first_aired': json_item['first_aired'], }) return episode_infos
def __movies_list_page(page, page_index, timeout=(network.TIMEOUT_CONNECT, network.TIMEOUT_READ)): json_data = network.json_get(TRAKT_URL + page, params={ 'page': page_index, 'limit': 31 }, headers=TRAKT_HEADERS, timeout=timeout) return __movie_list_parse(json_data)
def __movie_people(trakt_slug, timeout=(network.TIMEOUT_CONNECT, network.TIMEOUT_READ)): result = { 'cast': [], 'crew': { 'directing': [], 'production': [], 'writing': [] } } json_data = network.json_get(TRAKT_URL + '/movies/' + trakt_slug + '/people', params={'extended': 'images'}, headers=TRAKT_HEADERS, timeout=timeout) if 'cast' in json_data: for json_item in json_data['cast']: result['cast'].append({ 'name': json_item['person']['name'], 'headshot': json_item['person']['images']['headshot']['full'], 'character': json_item['character'] }) if 'crew' in json_data: if 'directing' in json_data['crew']: for json_item in json_data['crew']['directing']: result['crew']['directing'].append({ 'name': json_item['person']['name'], 'headshot': json_item['person']['images']['headshot']['full'], 'job': json_item['job'] }) if 'production' in json_data['crew']: for json_item in json_data['crew']['production']: result['crew']['production'].append({ 'name': json_item['person']['name'], 'headshot': json_item['person']['images']['headshot']['full'], 'job': json_item['job'] }) if 'writing' in json_data['crew']: for json_item in json_data['crew']['writing']: result['crew']['writing'].append({ 'name': json_item['person']['name'], 'headshot': json_item['person']['images']['headshot']['full'], 'job': json_item['job'] }) return result