Skip to content

Commit

Permalink
Merge branch 'hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantinos committed Jul 28, 2019
2 parents 8f96527 + a585f17 commit 938b1e5
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 47 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ Changelog
=========


1.1.4 (2019-07-28)
-------------------

Changes
^^^^^^^

- Fix track segmentation in linux systems.
- Settle for 9 minor and 3 medium issues of security severity


1.1.3 (2019-07-27)
-------------------

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ Overview
:alt: Supported versions
:target: https://pypi.org/project/music-album-creation

.. |commits_since| image:: https://img.shields.io/github/commits-since/boromir674/music-album-creator/v1.1.3.svg
.. |commits_since| image:: https://img.shields.io/github/commits-since/boromir674/music-album-creator/v1.1.4.svg
:alt: Commits since latest release
:target: https://github.com/boromir674/music-album-creator/compare/v1.1.3...master
:target: https://github.com/boromir674/music-album-creator/compare/v1.1.4...master


.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/music-album-creator.svg
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def readme():

setup(
name='music_album_creation',
version='1.1.3',
version='1.1.4',
description='A CLI application intending to automate offline music library building.',
long_description=readme(),
keywords='music automation download youtube metadata',
Expand Down
2 changes: 1 addition & 1 deletion src/music_album_creation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '1.1.3'
__version__ = '1.1.4'

from .tracks_parsing import StringParser
from .metadata import MetadataDealer
Expand Down
19 changes: 6 additions & 13 deletions src/music_album_creation/album_segmentation.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/python3

import subprocess
import time
from tempfile import mkdtemp
import subprocess

from music_album_creation.tracks_parsing import StringParser

Expand All @@ -11,11 +10,8 @@ class AudioSegmenter:

args = ['ffmpeg', '-i', '-acodec', 'copy', '-ss']

def __init__(self, target_directory=''):
if not target_directory:
self._dir = mkdtemp()
else:
self._dir = target_directory
def __init__(self, target_directory='/tmp'):
self._dir = target_directory

@property
def target_directory(self):
Expand All @@ -26,9 +22,6 @@ def target_directory(self):
def target_directory(self, directory_path):
self._dir = directory_path

def temp_location(self):
self._dir = mkdtemp()

def segment_from_file(self, album_file, tracks_file, supress_stdout=True, supress_stderr=True, verbose=False, sleep_seconds=0.45):
"""
Given an album audio file and a file with track information, segments the audio file into audio tracks which get stored in the 'self.target_directory' folder.\n
Expand All @@ -44,7 +37,7 @@ def segment_from_file(self, album_file, tracks_file, supress_stdout=True, supres
list_of_lists = StringParser.parse_hhmmss_string(f.read().strip())
self.segment_from_list(album_file, list_of_lists, supress_stdout=supress_stdout, supress_stderr=supress_stderr, verbose=verbose, sleep_seconds=sleep_seconds)

def segment_from_list(self, album_file, data, supress_stdout=True, supress_stderr=False, verbose=False, sleep_seconds=0):
def segment_from_list(self, album_file, data, supress_stdout=True, supress_stderr=True, verbose=False, sleep_seconds=0):
"""
Given an album audio file and data structure with tracks information, segments the audio file into audio tracks which get stored in the 'self.target_directory' folder.\n
:param str album_file:
Expand Down Expand Up @@ -84,8 +77,8 @@ def _segment(self, *args, supress_stdout=True, supress_stderr=True, verbose=Fals
self._args = self.args[:2] + [album_file] + self.args[2:] + [start] + (lambda: ['-to', str(end)] if end else [])() + [track_file]
if verbose:
print("Segmenting with '{}'".format(' '.join(self._args)))
# subprocess.call()
return subprocess.call(self._args, **self.__std_parameters(supress_stdout, supress_stderr))
ro = subprocess.run(self._args, **self.__std_parameters(supress_stdout, supress_stderr))
return ro.returncode

@classmethod
def __std_parameters(cls, std_out_flag, std_error_flag):
Expand Down
16 changes: 6 additions & 10 deletions src/music_album_creation/create_album.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import sys
import glob
import click
import shutil
import mutagen
import subprocess
from tempfile import mkdtemp, gettempdir
from time import sleep

from . import StringParser, MetadataDealer, AudioSegmenter, FormatClassifier
Expand Down Expand Up @@ -39,11 +39,10 @@
@click.option('--url', '-u', help='the youtube video url')
def main(tracks_info, track_name, track_number, artist, album_artist, url):
# CONFIG of the 'app' #
mkdtemp()
directory = gettempdir()
# if os.path.isdir(directory):
# shutil.rmtree(directory)
# os.mkdir(directory)
directory = '/tmp/gav'
if os.path.isdir(directory):
shutil.rmtree(directory)
os.mkdir(directory)
music_dir = '/media/kostas/freeagent/m'

## Render Logo
Expand Down Expand Up @@ -106,7 +105,7 @@ def main(tracks_info, track_name, track_number, artist, album_artist, url):
if answer.startswith('Durations'):
tracks_data = StringParser.duration_data_to_timestamp_data(tracks_data)
try: # SEGMENTATION
audio_files = audio_segmenter.segment_from_list(album_file, tracks_data, supress_stdout=False, verbose=True, sleep_seconds=0.4)
audio_files = audio_segmenter.segment_from_list(album_file, tracks_data, supress_stdout=True, verbose=True, sleep_seconds=0.4)
except TrackTimestampsSequenceError as e:
print(e)
sys.exit(1)
Expand Down Expand Up @@ -163,7 +162,4 @@ def listCompleter(text, state):
readline.set_completer_delims('\t')
readline.parse_and_bind("tab: complete")
readline.set_completer(completer.pathCompleter)

# if sys.version_info.major == 2: # if interpreter is python2 somehow (it will crash anyways)

main()
19 changes: 1 addition & 18 deletions src/music_album_creation/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __new__(cls, *args, **kwargs):
if not cls.__instance:
cls.__instance = super().__new__(cls)
if sys.version_info.major == 2:
cls.__instance._input = raw_input
cls.__instance._input = raw_input # NOQA
else:
cls.__instance._input = input
return cls.__instance
Expand Down Expand Up @@ -217,20 +217,3 @@ def set_metadata_panel(default_artist=artist, default_album=album, default_year=
return my_answers

return set_metadata_panel()


class InputFactory:
__instance = None
def __new__(cls, *args, **kwargs):
if not cls.__instance:
cls.__instance = super().__new__(cls)
if sys.version_info.major == 2:
cls.__instance._input = raw_input
else:
cls.__instance._input = input
return cls.__instance

def __call__(self, message):
if not message.endswith(': '):
message += ': '
return self._input(message)
14 changes: 12 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ commands =
[flake8]
# select the type of style errors to check
select = B,C,E,F,I,N,S,W
# disable skipping warning when '# noqa' is found
disable-noqa = True

# If True: disable skipping warning when '# noqa' is found
# If False: skips lines that have '# noqa'; does not check them
disable-noqa = False

# show the source file generating a warning
show-source = True
# check syntax of the doctests
Expand Down Expand Up @@ -177,6 +180,13 @@ commands =
coverage html


[testenv:py35-active]
basepython = {env:TOXPYTHON:python3.5}
usedevelop = true
commands =
create-album


[testenv:py35-cover]
basepython = {env:TOXPYTHON:python3.5}
setenv =
Expand Down

0 comments on commit 938b1e5

Please sign in to comment.