def update_log(args): anime_name, episodes = read_args(args) episodes = utils.compress_range(episodes) utils.write_log(anime_name, episodes) utils.update_tracklist(anime_name, episodes) utils.write_cache(anime_name) utils.update_watchlater(anime_name, episodes)
def search_results(s): all_res = s.find('ul', {'class': 'items'}) for list_item in all_res.find_all('li'): an = list_item.p.a['href'].split('/')[-1] utils.write_cache(an, append=True) outputs.normal_info(an, end=' \t') outputs.normal_info(list_item.p.a.text)
def search_results(s): all_res = s.find("ul", {"class": "items"}) for list_item in all_res.find_all("li"): an = list_item.p.a["href"].split("/")[-1] utils.write_cache(an, append=True) outputs.normal_info(an, end=" \t") outputs.normal_info(list_item.p.a.text)
def list_episodes(args): name = read_args(args, episodes=False) available_rng = gogoanime.get_episodes_range(gogoanime.get_anime_url(name)) if len(args) == 2: _, episodes = read_args(args) eps = set(episodes) avl_eps = set(utils.extract_range(available_rng)) res = eps.intersection(avl_eps) available_rng = utils.compress_range(res) outputs.prompt_val(f'Available episodes', available_rng) outputs.prompt_val(f'Watched episodes', utils.read_log(name), 'success') utils.write_cache(name)
def GET(self): params = web.input(reflash='true') res = {'actual_on': None, 'tests': []} if params.reflash == 'true': results = fit.check_results(team=params.team) utils.write_cache(results) res['tests'] = results elif params.reflash == 'false' and utils.has_cache(): res['tests'] = json.loads(utils.read_cache()) actual_on = utils.cache_time() res['actual_on'] = actual_on return json.dumps(res)
def list_episodes(args): name, _ = read_args(args, episodes=False) available_rng = anime_source_module.get_episodes_range(anime_source_module.get_anime_url(name)) if len(args) == 2: _, episodes = read_args(args) eps = set(episodes) avl_eps = set(utils.extract_range(available_rng)) res = eps.intersection(avl_eps) available_rng = utils.compress_range(res) outputs.prompt_val("Available episodes", available_rng) log = utils.Log(utils.read_log(name)) outputs.prompt_val("Watched episodes", log.eps, "success", end=' ') outputs.normal_info(log.last_updated_fmt) utils.write_cache(name)
def watch_episode_in_web(args): name, episodes = read_args(args, episodes=None) if not episodes: url = anime_source_module.get_anime_url(name) webbrowser.open_new_tab(url) return for e in episodes: url = anime_source_module.get_episode_url(name, e) webbrowser.open_new_tab(url) choice = input(f"did you watch the episode {e}? <Y/n>") if not choice.strip() or choice.strip() in 'Yy': utils.write_log(name, e) utils.update_tracklist(name, e) utils.write_cache(name) utils.update_watchlater(name, e)
def stream_from_url(url, anime_name=None, episode=None, *, local=False): if not anime_name or not episode: anime_name, episode = anime_source_module.parse_url(url) if local: durl = url _, ext = os.path.splitext(durl) else: outputs.normal_info("Getting Streaming Link:", url) durl, ext = anime_source_module.get_direct_video_url(url) if not durl: outputs.error_info("Url for the file not found") raise SystemExit outputs.prompt_val("Stream link", durl, "success") try: if config.ext_player_confirm: choice = input(f"Open {config.ext_player} Player? <Y/n>") if choice == "" or choice.lower() == "y": pass else: raise SystemExit else: for i in range(11): outputs.normal_info( f"\rOpening External Player in: {1-i/10:1.1f} sec.", end="") time.sleep(0.1) outputs.normal_info() retval = player_module.play_media( durl, title=f"ANIME:{anime_name}:ep-{episode}{ext}") if retval: utils.write_log(anime_name, episode) utils.update_tracklist(anime_name, episode) utils.write_cache(anime_name) utils.update_watchlater(anime_name, episode) return except KeyboardInterrupt: outputs.warning_info("\nInturrupted, Exiting...") raise SystemExit outputs.normal_info()
def stream_from_url(url, anime_name=None, episode=None): if not anime_name or not episode: anime_name, episode = gogoanime.parse_gogo_url(url) outputs.normal_info('Getting Streaming Link:', url) durl, ext = gogoanime.get_direct_video_url(url) if not durl: outputs.error_info('Url for the file not found') raise SystemExit if ext == 'm3u8': durl = utils.get_m3u8_stream(durl) outputs.prompt_val(f'Stream link', durl, 'success') try: for i in range(11): outputs.normal_info( f'\rOpening External Player in: {1-i/10:1.1f} sec.', end='') time.sleep(0.1) except KeyboardInterrupt: outputs.warning_info('\nInturrupted, Exiting...') raise SystemExit outputs.normal_info() while True: t1 = time.time() ret_val = subprocess.call(" ".join(config.ext_player_command + [durl]), shell=True) if ret_val == 2: # mpv error code outputs.error_info('Couldn\'t open the stream.') if input("retry?<Y/n>") == '': continue else: raise SystemExit if (time.time() - t1) > ( 5 * 60 ): # 5 minutes watchtime at least, otherwise consider it unwatched. # TODO: use direct communication with mpv to know if episode was watched. utils.write_log(anime_name, episode) utils.update_tracklist(anime_name, episode) utils.write_cache(anime_name) return