From 0340a470f91e7fedf18980f2245b639aaa10b4e2 Mon Sep 17 00:00:00 2001 From: Hellowlol Date: Mon, 7 May 2018 14:09:24 +0200 Subject: [PATCH 1/2] Update .coveragerc --- .coveragerc | 1 + 1 file changed, 1 insertion(+) diff --git a/.coveragerc b/.coveragerc index 6f236a9..5e3df9c 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,6 +5,7 @@ omit = bw_plex/audfprint/* [report] exclude_lines = pragma: no cover + if debug: raise NotImplementedError From 0958649389e59f4a2ab239ed5a4b48cae6f35216 Mon Sep 17 00:00:00 2001 From: heyyo Date: Thu, 10 May 2018 18:57:01 +0200 Subject: [PATCH 2/2] minor cleanup --- bw_plex/misc.py | 5 +++-- bw_plex/plex.py | 28 +++++----------------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/bw_plex/misc.py b/bw_plex/misc.py index ca19a63..da2f9a7 100644 --- a/bw_plex/misc.py +++ b/bw_plex/misc.py @@ -150,8 +150,9 @@ def get_offset_end(vid, hashtable, check_if_missing=False): nhashraw, rank, min_time, max_time) in rslts: end_time = max_time * t_hop start_time = min_time * t_hop - LOG.info('Match %s rank %s aligntime %s theme song %s started at %s (%s) in ended at %s (%s)' % (tophitid, rank, - aligntime, hashtable.names[tophitid], start_time, to_time(start_time), end_time, to_time(end_time))) + LOG.info('Match %s rank %s aligntime %s theme song %s started at %s (%s) in ended at %s (%s) duration %s (%s)' % (tophitid, rank, + aligntime, hashtable.names[tophitid], start_time, to_time(start_time), end_time, + to_time(end_time), end_time - start_time, to_time(end_time - start_time))) if len(rslts): best = rslts[0] diff --git a/bw_plex/plex.py b/bw_plex/plex.py index 027653b..7aa2ff4 100644 --- a/bw_plex/plex.py +++ b/bw_plex/plex.py @@ -293,7 +293,7 @@ def process(name, sample, threads, skip_done): for item in items: for ep in all_eps: if ep.ratingKey == item.ratingKey: - click.secho('Removing as %s already is processed' % item.prettyname, fg='red') + click.secho("Removing %s at it's already is processed" % item.prettyname, fg='red') all_eps.remove(ep) HT = get_hashtable() @@ -312,6 +312,7 @@ def process(name, sample, threads, skip_done): LOG.debug('Downloading theme for %s shows this might take a while..', len(gr)) if len(gr): sh = p.map(PMS.fetchItem, gr) + # FIX me. this does not work after multi themes try: p.map(HT.has_theme, sh) except KeyboardInterrupt: @@ -393,7 +394,7 @@ def manually_correct_theme(name, url, type, rk, just_theme): HT.remove(th) # Download the themes depending on the manual option or config file. - theme_path = download_theme(items[0], HT, theme_source=type, url=url) + download_theme(items[0], HT, theme_source=type, url=url) to_pp = [] # THis should be removed, if you just want to download the theme. use find theme. @@ -413,6 +414,7 @@ def manually_correct_theme(name, url, type, rk, just_theme): for media in to_pp: process_to_db(media) + @cli.command() @click.option('-s', '--show', default=None) @click.option('-t', '--type', default='youtube') @@ -505,8 +507,6 @@ def export_db(format, save_path, write_file, show_html): """Test command for myself.""" import tablib - f = Preprocessed - keys = [k for k in Preprocessed.__dict__.keys() if not k.startswith('_')] data = [] @@ -646,27 +646,9 @@ def task(item, sessionkey): if media.TYPE not in ('episode', 'show'): return - #if not HT.get_theme(media): - LOG.debug('Download the first 10 minutes of %s as .wav', media._prettyfilename()) vid = convert_and_trim(check_file_access(media), fs=11025, trim=600) - # Check if this shows theme exist in the hash table. - # We should prop just check if x in HT.names - #try: - # HT.name_to_id(theme) - #except ValueError: - # LOG.debug('No fingerprint for theme %s does exists in the %s', - # os.path.basename(theme), FP_HASHES) - - # analyzer().ingest(HT, theme) - #HT = HT.save_then_reload(FP_HASHES) - - #start, end = get_offset_end(vid, HT) - #ffmpeg_end = find_offset_ffmpeg(check_file_access(media)) - #if end != -1 or ffmpeg_end != 1: - # # End is -1 if not found. Or a positiv int. - # process_to_db(media, theme=theme, vid=vid, start=start, end=end, ffmpeg_end=ffmpeg_end) process_to_db(media, vid=vid) try: @@ -784,7 +766,7 @@ def watch(): try: while True: - time.sleep(0.0001) + time.sleep(0.2) except KeyboardInterrupt: click.echo('Aborting') ffs.stop()