Commit Graph

1480 Commits

Author SHA1 Message Date
JoeLametta
ee11fac1da Merge pull request #458 from kevinoid/fix-cover-tmp-fs
Fix cover file saving with /tmp on different FS
2020-01-28 17:31:09 +01:00
Kevin Locke
b6607c6573 Fix cover file saving with /tmp on different FS
If the directory used by tempfile.NamedTemporaryFile is on a different
filesystem (e.g. /tmp on tmpfs), `whipper cd rip --cover-art` will fail
with an error such as:

    Traceback (most recent call last):
      File "/usr/bin/whipper", line 11, in <module>
        load_entry_point('whipper==0.9.0', 'console_scripts', 'whipper')()
      File "/home/kevin/tmp/whipper/whipper/command/main.py", line 43, in main
        ret = cmd.do()
      File "/home/kevin/tmp/whipper/whipper/command/basecommand.py", line 139, in do
        return self.cmd.do()
      File "/home/kevin/tmp/whipper/whipper/command/basecommand.py", line 139, in do
        return self.cmd.do()
      File "/home/kevin/tmp/whipper/whipper/command/cd.py", line 191, in do
        self.doCommand()
      File "/home/kevin/tmp/whipper/whipper/command/cd.py", line 363, in doCommand
        self.program.metadata.mbid)
      File "/home/kevin/tmp/whipper/whipper/common/program.py", line 498, in getCoverArt
        os.replace(f.name, cover_art_path)
    OSError: [Errno 18] Invalid cross-device link: '/tmp/tmprmx4d9c9.cover.jpg' -> './Boston/Greatest Hits/cover.jpg'

due to calling os.replace with paths on different filesystems.

Instead of os.replace, use shutil.move, which falls back to shutil.copy2
if os.replace doesn't work.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
2020-01-26 17:37:11 -07:00
JoeLametta
553a6de88f Fix typo in README and clarify Docker instructions
Fixes #452.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2020-01-17 15:42:06 +00:00
JoeLametta
caa2c8b27d Bug: whipper shouldn't abort if track rip succeeds on last allowed retry attempt
Fixes #449.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2020-01-14 17:50:04 +00:00
JoeLametta
9e37219401 Merge pull request #436 from ABCbum/grab-cover-art
Grab cover art from MusicBrainz/Cover Art Archive and add it to the resulting whipper rips
2020-01-14 17:04:53 +01:00
ABCbum
e2942b07e3 Add test case to check getCoverArt's functionality
Mock two functions `getCoverArt`, `get_image_front` and use
a locally available cover art to check if the created cover
art exists.

Problems:
- How to check image's quality.
- Not sure if only this check is enough (do we need to check the
embedding part?).

Signed-off-by: ABCbum <kimlong221002@gmail.com>
2020-01-14 15:57:34 +00:00
ABCbum
8181cacca5 Update README, dependencies and supporting files for cover art feature
Signed-off-by: ABCbum <kimlong221002@gmail.com>
Co-authored-by: JoeLametta <JoeLametta@users.noreply.github.com>
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2020-01-14 15:57:34 +00:00
ABCbum
f61214a238 Support fetching cover art images from the Cover Art Archive
Add option `--cover-art` to `whipper cd rip` command which accepts three values:
- `file`: save the downloaded cover image as standalone file in the rip folder (named `cover.jpg`)
- `embed`: embed the download cover image into all the ripped audio tracks (no standalone file will be kept)
- `complete`: save standalone cover image as standalone file and embed it into all the ripped audio tracks (`file` + `embed`)

Every cover art is fetched from the Cover Art Archive as JPEG thumbnail with a maximum dimension of 500px.
Other supported values for the thumbnails are 250, 500 and 1200 (currently only some images have a corresponding 1200px sized thumbnail).

This feature introduces an optional dependency on the `Pillow` module which is required for the decoding of the cover file (required by the `embed` and `complete` option values).

Problem:
- EmbedPicTureTask shouldn't be a task.

Signed-off-by: ABCbum <kimlong221002@gmail.com>
Co-authored-by: JoeLametta <JoeLametta@users.noreply.github.com>
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2020-01-14 15:57:34 +00:00
JoeLametta
6a43d7df1a Update copyright year in README
Misc README changes too.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2020-01-10 18:10:12 +00:00
JoeLametta
150f0d5e91 Move inline comment to separate line in example whipper config file
This avoids `%` character interpolation leading to `InterpolationSyntaxError`.
Added a comment explaining this too.

Fixes #443.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2020-01-04 15:35:32 +00:00
JoeLametta
fb9fb34b83 Move comment to the right place
The blank line after the comment was added in commit 644e67f105.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2020-01-04 12:21:08 +00:00
JoeLametta
d665fe44c4 Fix single wrong line order in README
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-12-29 15:14:24 +00:00
JoeLametta
25104145f0 Merge pull request #435 from ABCbum/develop
Fix whipper's MusicBrainz Disc ID calculation for CDs with data tracks that are not positioned at the end of the disc
2019-12-28 13:56:14 +01:00
ABCbum
8c41f4ddb3 Update whipper's dependencies
whipper now requires `discid` package - which can be installed through
pip and `discid` relies on libdiscid.

Signed-off-by: ABCbum <kimlong221002@gmail.com>
2019-12-28 12:42:26 +00:00
ABCbum
97ffd0fe4d Add test case when data track is first track
Using existing TOCs, create a new test case to verify discid generated
when data track is not at the end of the disc track-list.

Quality of test is not verified.

Signed-off-by: ABCbum <kimlong221002@gmail.com>
2019-12-28 12:42:26 +00:00
ABCbum
a113404c33 Replace whipper's disc id calculation with discid
Since whipper's own "musicbrainz id calculation" fails on CDs with data
tracks on special places, the disc id calculation code is replaced with
libdiscid.

Gives a new way to calculate disc leadout or sectors (last sector of last
audio track) depends on whether the data track is placed last or not.

`discid` requires `len(track_offsets) != last - first + 1`.Which means
there can be only one data track in the disc and the lastTrack number is
deceptive.

For example: a disc (data audio audio audio) has firstTrack=1 lastTrack=3
which is wrong since according to the discid code :
    "last **audio** track as :obj:`int"
it should be 4 but the firstTrack is always 1.

The code is duplicated with _getMusicBrainzValues function.

Signed-off-by: ABCbum <kimlong221002@gmail.com>
2019-12-28 12:42:26 +00:00
JoeLametta
8f5559ebc8 Merge pull request #432 from ABCbum/develop
Allow whipper's mblookup command to look up information based on Release MBID
2019-12-19 10:01:10 +01:00
ABCbum
bb66a092cd Add test case to new mblookup functionality
A new test case to check for mblookup's ability to search
for data based on release id is created along with a function
mocks getReleaseMetadata using an existing JSON file.

Signed-off-by: ABCbum <kimlong221002@gmail.com>
2019-12-19 08:56:00 +00:00
ABCbum
78c91fd1c7 Add new functionality and refactor code
In order to make mblookup command able to lookup data based
on release id, new function getReleaseMetadata is created.
To remove duplicated code, importing and set_useragent is moved
to the top of the file.
Now _getMetadata behaves differently when the discid is not
specified.

Signed-off-by: ABCbum <kimlong221002@gmail.com>
2019-12-19 08:55:54 +00:00
ABCbum
b914b31119 Enable mblookup to take release id as argument
To make mblookup able to look up data based on release id,
RegExp is used to detect whether the input is release id
or disc id and behaves differently according to that.
The input is now also tripped before being passed down.

Signed-off-by: ABCbum <kimlong221002@gmail.com>
2019-12-19 08:55:13 +00:00
JoeLametta
9e95f0604f Merge pull request #434 from Freso/issue-431-broken-drive-analyze
Fix failed() task of AnalyzeTask (program/cdparanoia)
2019-12-15 16:55:10 +01:00
Merlijn Wajer
29ee670b7f program/cdparanoia: fix failed() task of AnalyzeTask
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-12-15 15:48:30 +00:00
Frederik “Freso” S. Olesen
4234c8fe8e Test against Python versions 3.6, 3.7, and 3.8
https://github.com/whipper-team/whipper/pull/433
2019-12-15 01:09:46 +01:00
Frederik “Freso” S. Olesen
7ad4265b18 Only run linting tests for one Python version
This creates a specific job with the `FLAKE8` variable set, rather than
a setting up a 4×2 matrix. This means we create a total of 5 jobs now
rather than 8 jobs.

Part of https://github.com/whipper-team/whipper/pull/433

Signed-off-by: Frederik “Freso” S. Olesen <freso.dk@gmail.com>
2019-12-15 01:06:05 +01:00
Frederik “Freso” S. Olesen
eca3be017a Test against Python versions 3.6, 3.7, and 3.8
Right now tests are only run against Python 3.5, but we claim we support
Python 3.5+ so let’s run our tests against both Python 3.5 and all later
(stable) versions.

PR: https://github.com/whipper-team/whipper/pull/433

Signed-off-by: Frederik “Freso” S. Olesen <freso.dk@gmail.com>
2019-12-15 00:57:37 +01:00
ABCbum
31d589b00d Enable whipper to use track title (#430)
* Enable whipper to use track title if possible

track.title = t.get('title', t['recording']['title']).

Since if a track itself doesn't have a title then the track
title is the same with the recording title. Otherwise, a track
has its own title then t['title'] is different from
t['recording']['title'] and whipper chooses t['title'].

[Fixes #192]
Signed-off-by: ABCbum <kimlong221002@gmail.com>

* Add test case to check for track title

Using an existing JSON release file

Signed-off-by: ABCbum <kimlong221002@gmail.com>
2019-12-13 18:43:48 +01:00
JoeLametta
6e3e21f9d5 Merge branch 'master' into develop 2019-12-04 14:46:22 +01:00
JoeLametta
b1718a2a68 Merge branch 'develop' 2019-12-04 13:29:08 +00:00
JoeLametta
c13f541e61 Push whipper release v0.9.0
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-12-04 13:26:33 +00:00
JoeLametta
bc31b98b32 Fix offsets.py output
Every line, except the last one, of the output was missing a double quote character at the end.

Additional changes:
- Specify parser to avoid BeautifulSoup warning
- Use single quotes only

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-12-04 13:14:24 +00:00
JoeLametta
d5bf83e4cc Whipper's version RegEX: support all valid scheme cases
Initial work by ArchangeGabriel: https://github.com/whipper-team/whipper/pull/421

Fixes #420.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-12-03 10:53:05 +00:00
Merlijn Wajer
47c62a9990 Fix regression introduced in Python 3 port
Fixes #424.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-12-03 10:39:46 +00:00
JoeLametta
bbd28c668f Reduce Docker image size
- Removed useless apt cache from layer 3
- Avoid installing apt recommended packages

The compressed image now weights 67 MB less (≈ -30% size).

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-11-27 22:05:36 +00:00
JoeLametta
d0efd74162 Merge pull request #411 from ddevault/py3
Python 3 port

From now on whipper's codebase will be compatible only with Python 3.
NOTE: This pull request introduces a regression: more details in #424.

Special thanks to @ddevault for kickstarting the porting effort!
2019-11-26 19:59:42 +01:00
JoeLametta
50c8cbb237 Update README, .travis.yml and Dockerfile for Python 3
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-11-26 18:48:01 +00:00
JoeLametta
42019ce85f Port (misc) offsets script to Python 3
I've also changed the output format a bit.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-11-26 18:48:01 +00:00
JoeLametta
bb4c25df97 Address ResourceWarning warnings
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-11-26 18:48:01 +00:00
JoeLametta
fff3014e15 Address test failures
More details about the fix to the testDuration failure (regression):

```
FAIL: testDuration (whipper.test.test_image_toc.CapitalMergeTestCase)
testDuration
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/twisted/internet/defer.py", line 151, in maybeDeferred
    result = f(*args, **kw)
  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/twisted/internet/utils.py", line 221, in runWithWarningsSuppressed
    reraise(exc_info[1], exc_info[2])
  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/twisted/python/compat.py", line 464, in reraise
    raise exception.with_traceback(traceback)
  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/twisted/internet/utils.py", line 217, in runWithWarningsSuppressed
    result = f(*a, **kw)
  File "/home/travis/build/whipper-team/whipper/whipper/test/test_image_toc.py", line 271, in testDuration
    self.assertEqual(self.table.getFrameLength(), 173530)
  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/twisted/trial/_synctest.py", line 432, in assertEqual
    super(_Assertions, self).assertEqual(first, second, msg)
  File "/opt/python/3.5.6/lib/python3.5/unittest/case.py", line 829, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/opt/python/3.5.6/lib/python3.5/unittest/case.py", line 822, in _baseAssertEqual
    raise self.failureException(msg)
twisted.trial.unittest.FailTest: 184930 != 173530
```

The test fails because if either nextTrack.session or thisTrack.session are None the if is false and the instructions inside it aren't executed. The check for None is needed because Python 3 doesn't allow NoneType comparisons (in Python 2 that was possible).
IIRC correctly in that test nextTrack.session has value 2 while thisTrack.session is None. That means the Python 2 version evaluates the if condition to true, while the Python 3 version in the first commit does not.
With this change both of the values of nextTrack.session and thisTrack.session are compared as int (if None, the value 1 is used for the comparison - as in disc session 1).

Regression introduced in 64dd9d843a.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-11-26 18:47:54 +00:00
JoeLametta
35201d5290 Address errors, improvements, formatting
- Removed unused code not portable due to buffer() use
- raw_input() does not exist in Python 3
- Fixed octal constant syntax for Python 3
- Fixed TypeError
- Replace if not exists: makedirs(path) with single call: using makedirs(path, exist_ok=True)
- Class inherits from object, can be safely removed from bases in python3: pylint's useless-object-inheritance (W0235) check

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-11-26 18:46:12 +00:00
Andreas Oberritter
8446c290e7 accuraterip-checksum.c: Port to Python 3
Accuraterip-checksum extension will be Python 3 only (JoeLametta).

Co-authored-by: JoeLametta <JoeLametta@users.noreply.github.com>
Signed-off-by: Andreas Oberritter <obi@saftware.de>
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-11-26 18:46:12 +00:00
JoeLametta
b2d06645af Address Freso's comment
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-11-26 18:46:12 +00:00
Drew DeVault
64dd9d843a Initial pass on python 3 port
Given the imminent end-of-life for Python 2, I didn't bother making the
codebase compatible with both.

Signed-off-by: Drew DeVault <sir@cmpwn.com>
2019-11-26 18:46:10 +00:00
JoeLametta
af067182e9 Add greetings action
Remove configuration files of unused probot apps too.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-11-14 15:08:23 +00:00
JoeLametta
f740a0ef0d Add missing backslash to RegEX
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-11-01 09:26:42 +00:00
Frederik “Freso” S. Olesen
42638f6e21 Merge branch 'master' into develop
(To make versioning work properly for the develop branch, since
currently the v0.8.0 tag only exists in the master branch. This merge
will pull the v0.8.0 tagged commit into the develop branch too.)
2019-10-31 19:36:54 +01:00
JoeLametta
484b2f18b7 Add missing dependency to Dockerfile
Fixes #419.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-10-28 16:07:26 +00:00
JoeLametta
4238e714be Merge branch 'develop' 2019-10-27 13:30:33 +00:00
JoeLametta
db9c44a765 Push whipper v0.8.0 release
Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
2019-10-27 13:30:18 +00:00
JoeLametta
8e60fb9a18 Merge pull request #415 from itismadness/ruamel_yaml
Use ruamel.yaml for formatting and outputting rip .log file
2019-10-27 09:11:49 +01:00
itismadness
3cd2da79c3 write unit test case for WhipperLogger
Signed-off-by: itismadness <itismadness@users.noreply.github.com>
2019-10-27 08:00:00 +00:00