def search_argenteam_api(search_string): url = api_search_url + "?q=" + urllib.quote_plus(search_string) content, response_url = geturl(url) response = json.loads(content) subs = [] if response['total'] > 0: for result in response['results']: if result['type'] == "tvshow" or result['type'] == "episode": subs.extend(search_tvshow(result)) elif result['type'] == "movie": subs.extend(search_movie(result['id'])) append_subtitle(subs)
def search_pack(search_string): url = main_url_search + urllib.quote_plus(search_string) content, response_url = geturl(url) #Check if gives more than tv show or movie pack pack_urls = [] for matches in re.finditer(search_results_pattern, content, re.IGNORECASE | re.DOTALL | re.MULTILINE | re.UNICODE): tipo = matches.group(2) id = matches.group(3) link = matches.group(4) url_subtitle = "http://www.argenteam.net/" + tipo +"/"+ id +"/"+link print url_subtitle pack_urls.append(url_subtitle) subs = [] if len(pack_urls) > 0: for url_pack in pack_urls: pack_content, response_url = geturl(url_pack) subs.extend(search_common(pack_content)) else: subs.extend(search_common(content)) append_subtitle(subs)
def search_tvshow(result): #log(__name__, "Search tvshow = %s" % tvshow) subs = [] if result['type'] == "tvshow": url = api_tvshow_url + "?id=" + str(result['id']) content, response_url = geturl(url) content = content.replace("null", '""') result_json = json.loads(content) for season in result_json['seasons']: for episode in season['episodes']: subs.extend(search_episode(episode['id'])) elif result['type'] == "episode": subs.extend(search_episode(result['id'])) return subs
def search_movie(movie_id): url = api_movie_url + "?id=" + str(movie_id) content, response_url = geturl(url) return search_common(content)
def search_episode(episode_id): url = api_episode_url + "?id=" + str(episode_id) content, response_url = geturl(url) return search_common(content)