Hello community, here is the log from the commit of package r128gain for openSUSE:Factory checked in at 2020-02-03 11:15:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/r128gain (Old) and /work/SRC/openSUSE:Factory/.r128gain.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "r128gain" Mon Feb 3 11:15:03 2020 rev:2 rq:769354 version:1.0.1 Changes: -------- --- /work/SRC/openSUSE:Factory/r128gain/r128gain.changes 2020-01-15 16:50:09.921340978 +0100 +++ /work/SRC/openSUSE:Factory/.r128gain.new.26092/r128gain.changes 2020-02-03 11:15:09.881900925 +0100 @@ -1,0 +2,7 @@ +Sun Feb 2 13:51:04 UTC 2020 - Martin Hauke <[email protected]> + +- Update to version 1.0.1 + * Logging fix + * Improve & refractor recursive progress report + +------------------------------------------------------------------- Old: ---- r128gain-1.0.0.tar.gz New: ---- r128gain-1.0.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ r128gain.spec ++++++ --- /var/tmp/diff_new_pack.3qAYNC/_old 2020-02-03 11:15:11.757901873 +0100 +++ /var/tmp/diff_new_pack.3qAYNC/_new 2020-02-03 11:15:11.785901888 +0100 @@ -1,6 +1,7 @@ # # spec file for package r128gain # +# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2020, Martin Hauke <[email protected]> # # All modifications and additions to the file contributed by third parties @@ -17,20 +18,20 @@ Name: r128gain -Version: 1.0.0 +Version: 1.0.1 Release: 0 Summary: Fast audio loudness (ReplayGain / R128) scanner & tagger -License: LGPL-2.0 +License: LGPL-2.0-only Group: Productivity/Multimedia/Sound/Players URL: https://github.com/desbma/r128gain Source: https://github.com/desbma/r128gain/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz BuildRequires: fdupes BuildRequires: python-rpm-macros BuildRequires: python3-setuptools -Requires: python3-future Requires: python3-crcmod >= 1.7 Requires: python3-ffmpeg-python >= 0.2 -Requires: python3-mutagen >= 1.38 +Requires: python3-future +Requires: python3-mutagen >= 1.43 Requires: python3-tqdm >= 4.28.1 BuildArch: noarch ++++++ r128gain-1.0.0.tar.gz -> r128gain-1.0.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/r128gain-1.0.0/freeze.py new/r128gain-1.0.1/freeze.py --- old/r128gain-1.0.0/freeze.py 2020-01-12 01:55:20.000000000 +0100 +++ new/r128gain-1.0.1/freeze.py 2020-02-02 14:23:54.000000000 +0100 @@ -9,7 +9,8 @@ with open(os.path.join("r128gain", "__init__.py"), "rt") as f: version = re.search("__version__ = \"([^\"]+)\"", f.read()).group(1) -build_exe_options = {"optimize": 0} +build_exe_options = {"optimize": 0, + "excludes": ["tkinter"]} setup(name="r128gain", version=version, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/r128gain-1.0.0/r128gain/__init__.py new/r128gain-1.0.1/r128gain/__init__.py --- old/r128gain-1.0.0/r128gain/__init__.py 2020-01-12 01:55:20.000000000 +0100 +++ new/r128gain-1.0.1/r128gain/__init__.py 2020-02-02 14:23:54.000000000 +0100 @@ -2,7 +2,7 @@ """ Scan audio files and tag them with ReplayGain/R128 loudness metadata. """ -__version__ = "1.0.0" +__version__ = "1.0.1" __author__ = "desbma" __license__ = "LGPLv2" @@ -20,6 +20,7 @@ import shutil import subprocess import sys +import threading import ffmpeg import mutagen @@ -42,12 +43,28 @@ RG2_REF_R128_LOUDNESS_DBFS = -18 OPUS_REF_R128_LOUDNESS_DBFS = -23 ALBUM_GAIN_KEY = 0 +try: + OPTIMAL_THREAD_COUNT = len(os.sched_getaffinity(0)) +except AttributeError: + OPTIMAL_THREAD_COUNT = os.cpu_count() def logger(): return logging.getLogger("r128gain") [email protected] +def dynamic_tqdm(*tqdm_args, **tqdm_kwargs): + """ Context manager that returns a tqdm object or None depending on context. """ + with contextlib.ExitStack() as cm: + if sys.stderr.isatty() and logger().isEnabledFor(logging.INFO): + progress = cm.enter_context(tqdm.tqdm(*tqdm_args, **tqdm_kwargs)) + cm.enter_context(tqdm_logging.redirect_logging(progress)) + else: + progress = None + yield progress + + def is_audio_filepath(filepath): """ Return True if filepath is a supported audio file. """ # TODO more robust way to identify audio files? (open with mutagen?) @@ -85,8 +102,12 @@ ":".join("%s=%s" % (k, v) for k, v in params.items())) -def get_r128_loudness(audio_filepaths, *, calc_peak=True, enable_ffmpeg_threading=True, ffmpeg_path=None): +def get_r128_loudness(audio_filepaths, *, calc_peak=True, enable_ffmpeg_threading=True, ffmpeg_path=None, + start_evt=None): """ Get R128 loudness loudness level and sample peak. """ + if start_evt is not None: + start_evt.wait() + logger().info("Analyzing loudness of file%s %s..." % ("s" if (len(audio_filepaths) > 1) else "", ", ".join("'%s'" % (audio_filepath) for audio_filepath in audio_filepaths))) @@ -171,17 +192,14 @@ def scan(audio_filepaths, *, album_gain=False, skip_tagged=False, thread_count=None, ffmpeg_path=None, executor=None, - progress=None, boxed_error_count=None): + progress=None, boxed_error_count=None, start_evt=None): """ Analyze files, and return a dictionary of filepath to loudness metadata or filepath to future if executor is not None. """ r128_data = {} with contextlib.ExitStack() as cm: if executor is None: if thread_count is None: - try: - thread_count = len(os.sched_getaffinity(0)) - except AttributeError: - thread_count = os.cpu_count() + thread_count = OPTIMAL_THREAD_COUNT enable_ffmpeg_threading = thread_count > (len(audio_filepaths) + int(album_gain)) executor = cm.enter_context(concurrent.futures.ThreadPoolExecutor(max_workers=thread_count)) asynchronous = False @@ -208,7 +226,8 @@ audio_filepaths, calc_peak=calc_album_peak, enable_ffmpeg_threading=enable_ffmpeg_threading, - ffmpeg_path=ffmpeg_path) + ffmpeg_path=ffmpeg_path, + start_evt=start_evt) futures[future] = ALBUM_GAIN_KEY for audio_filepath in audio_filepaths: if skip_tagged and has_loudness_tag(audio_filepath)[0]: @@ -225,7 +244,8 @@ (audio_filepath,), calc_peak=calc_peak, enable_ffmpeg_threading=enable_ffmpeg_threading, - ffmpeg_path=ffmpeg_path) + ffmpeg_path=ffmpeg_path, + start_evt=start_evt) futures[future] = audio_filepath if asynchronous: @@ -471,16 +491,10 @@ """ Analyze and tag input audio files. """ error_count = 0 - with contextlib.ExitStack() as cm: - if sys.stderr.isatty() and logging.getLogger().isEnabledFor(logging.INFO): - progress = cm.enter_context(tqdm.tqdm(total=len(audio_filepaths) + int(album_gain), - desc="Analyzing audio loudness", - unit=" files", - leave=False)) - cm.enter_context(tqdm_logging.redirect_logging(progress)) - else: - progress = None - + with dynamic_tqdm(total=len(audio_filepaths) + int(album_gain), + desc="Analyzing audio loudness", + unit=" files", + leave=False) as progress: # analyze files r128_data = scan(audio_filepaths, album_gain=album_gain, @@ -531,43 +545,60 @@ """ Analyze and tag all audio files recursively found in input directories. """ error_count = 0 - if thread_count is None: - try: - thread_count = len(os.sched_getaffinity(0)) - except AttributeError: - thread_count = os.cpu_count() - - futures = {} - with concurrent.futures.ThreadPoolExecutor(max_workers=thread_count) as executor, \ - contextlib.ExitStack() as cm: - if sys.stderr.isatty() and logging.getLogger().isEnabledFor(logging.INFO): - progress = cm.enter_context(tqdm.tqdm(total=0, - desc="Analyzing audio loudness", - unit=" files", - leave=False)) - cm.enter_context(tqdm_logging.redirect_logging(progress)) - else: - progress = None - - # walk directories, start analysis + # walk directories + albums_filepaths = [] + walk_stats = collections.OrderedDict(((k, 0) for k in("files", "dirs"))) + with dynamic_tqdm(desc="Analyzing directories", + unit=" dir", + postfix=walk_stats, + leave=False) as progress: for input_directory in directories: for root_dir, subdirs, filepaths in os.walk(input_directory, followlinks=False): audio_filepaths = tuple(map(functools.partial(os.path.join, root_dir), filter(is_audio_filepath, filepaths))) if audio_filepaths: - dir_futures = scan(audio_filepaths, - album_gain=album_gain, - skip_tagged=skip_tagged, - ffmpeg_path=ffmpeg_path, - executor=executor) - dir_futures = {k: (tuple(f for f in dir_futures.keys() if f is not k), v) for k, v in dir_futures.items()} - futures.update(dir_futures) + albums_filepaths.append(audio_filepaths) - if progress is not None: - progress.total += len(audio_filepaths) + int(album_gain) + if progress is not None: + walk_stats["files"] += len(filepaths) + walk_stats["dirs"] += 1 + progress.set_postfix(walk_stats, refresh=False) + progress.update(1) + + # get optimal thread count + if thread_count is None: + thread_count = OPTIMAL_THREAD_COUNT + executor = concurrent.futures.ThreadPoolExecutor(max_workers=thread_count) + start_evt = threading.Event() + futures = {} + + with dynamic_tqdm(total=len(albums_filepaths), + desc="Building work queue", + unit=" albums", + leave=False) as progress: + # analysis futures + for album_filepaths in albums_filepaths: + dir_futures = scan(album_filepaths, + album_gain=album_gain, + skip_tagged=skip_tagged, + ffmpeg_path=ffmpeg_path, + executor=executor, + start_evt=start_evt) + dir_futures = {k: (tuple(f for f in dir_futures.keys() if f is not k), v) for k, v in dir_futures.items()} + futures.update(dir_futures) + + if progress is not None: + progress.update(1) + + with dynamic_tqdm(total=sum(map(len, albums_filepaths)) + int(album_gain) * len(albums_filepaths), + desc="Analyzing audio loudness", + unit=" files", + leave=False, + smoothing=0) as progress: # get results + start_evt.set() pending_futures = futures while futures: done_futures, pending_futures = concurrent.futures.wait(pending_futures, @@ -651,6 +682,8 @@ for to_del_future in to_del_futures: del futures[to_del_future] + executor.shutdown(True) + return error_count diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/r128gain-1.0.0/requirements.txt new/r128gain-1.0.1/requirements.txt --- old/r128gain-1.0.0/requirements.txt 2020-01-12 01:55:20.000000000 +0100 +++ new/r128gain-1.0.1/requirements.txt 2020-02-02 14:23:54.000000000 +0100 @@ -1,4 +1,4 @@ crcmod>=1.7 ffmpeg-python~=0.2 -mutagen>=1.38 +mutagen>=1.43 tqdm>=4.28.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/r128gain-1.0.0/win/Makefile new/r128gain-1.0.1/win/Makefile --- old/r128gain-1.0.0/win/Makefile 2020-01-12 01:55:20.000000000 +0100 +++ new/r128gain-1.0.1/win/Makefile 2020-02-02 14:23:54.000000000 +0100 @@ -1,12 +1,12 @@ WINEARCH ?= win32 -FFMPEG_VERSION ?= 3.4 +FFMPEG_VERSION ?= 4.2 FFMPEG_CACHE_DIR ?= ${HOME}/.cache/ci/r128gain/ffmpeg-${WINEARCH} # versions PYTHON_VERSION := 3.6.8 PYTHON_VERSION_MAJOR := $(word 1,$(subst ., ,${PYTHON_VERSION})).$(word 2,$(subst ., ,${PYTHON_VERSION})) PYTHON_VERSION_SHORT := $(subst .,,${PYTHON_VERSION_MAJOR}) -CXFREEZE_VERSION := 5.1.1 +CXFREEZE_VERSION := 6.1 SOX_VERSION := 14.4.2 # installers @@ -159,11 +159,11 @@ ${CXFREEZE_WHEEL-win32}: mkdir -p $(dir $@) - ${CURL} https://pypi.python.org/packages/3b/04/d68567b8f3265d3936e37c1ee8b3378dc189ec66b4d43650affbefcc69c5/$(notdir $@) > $@ + ${CURL} https://files.pythonhosted.org/packages/ea/2b/076f152fdaff10a08ca4012713532b6d2606c1995ee85812d271135f90e2/$(notdir $@) > $@ ${CXFREEZE_WHEEL-win64}: mkdir -p $(dir $@) - ${CURL} https://pypi.python.org/packages/49/2b/07fc4cfff671ea348b310400e4f13a596e02079afc6bd1c33150b2cf30de/$(notdir $@) > $@ + ${CURL} https://files.pythonhosted.org/packages/50/dc/ad7111fc626a24504e468382c431698e4dcd60c944b9e9adf2187d073865/$(notdir $@) > $@ ${7ZIP_INSTALLER}: mkdir -p $(dir $@)
