Code Monkey home page Code Monkey logo

beets-copyartifacts's Introduction

THIS BEETS PLUGIN IS NO LONGER BEING MAINTAINED

I no longer have time to maintain this plugin. Thank you to all those involved for their contributions.

Some alternatives have been described on issue #31, notably:

copyartifacts plugin for beets

https://travis-ci.org/sbarakat/beets-copyartifacts.svg?branch=master

A plugin that moves non-music files during the import process.

This is a plugin for beets: a music library manager and much more.

Installing

Stable

The stable version of the plugin is available from PyPI. Installation can be done using pip:

pip install beets-copyartifacts

If you get permission errors try running it with sudo

Development

The development version can be installed from GitHub by using these commands:

git clone https://github.com/sbarakat/beets-copyartifacts.git
cd beets-copyartifacts
python setup.py install

If you get permission errors try running it with sudo

Configuration

You will need to enable the plugin in beets' config.yaml

plugins: copyartifacts

It can copy files by file extenstion:

copyartifacts:
    extensions: .cue .log

Or copy all non-music files (it does this by default):

copyartifacts:
    extensions: .*

It can also print what got left:

copyartifacts:
    print_ignored: yes

Renaming files

Renaming works in much the same way as beets Path Formats with the following limitations: - The fields available are $artist, $albumartist, $album and $albumpath. - The full set of built in functions are also supported, with the exception of %aunique - which will return an empty string.

Each template string uses a query syntax for each of the file extensions. For example the following template string will be applied to .log files:

paths:
    ext:log: $albumpath/$artist - $album

This will rename a log file to: ~/Music/Artist/2014 - Album/Artist - Album.log

Example config

plugins: copyartifacts

paths:
    default: $albumartist/$year - $album/$track - $title
    singleton: Singletons/$artist - $title
    ext:log: $albumpath/$artist - $album
    ext:cue: $albumpath/$artist - $album
    ext:jpg: $albumpath/cover

copyartifacts:
    extensions: .cue .log .jpg
    print_ignored: yes

Thanks

copyartifacts was built on top of the hard work already done by Adrian Sampson and the larger community on beets. We have also benefited from the work of our contributors.

This plugin was built out of necessity and to scratch an itch. It has gained a bit of attention, so I intend to maintain it where I can, however I doubt I will be able to spend large amount of time on it. Please report any issues you may have and feel free to contribute.

License

Copyright (c) 2015-2017 Sami Barakat

Licensed under the MIT license.

beets-copyartifacts's People

Contributors

jlefley avatar mried avatar sbarakat avatar twal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

beets-copyartifacts's Issues

Not looking for underlying directory

Some of the folders I want to import have underlying directories with the artwork and log files in them.
Is there a way to also detect those files?

copy with copyartifacts doubles the files

Hi, i have an strange issue here.
archlinux
beets version 1.4.3
Python version 3.6.0
plugins: acousticbrainz, bucket, chroma, copyartifacts, discogs, fetchart, fuzzy, inline, lastgenre, lastimport, lyrics, missing, replaygain, web

copyartifacts:
extensions: .*
print_ignored: yes

beets-copyartifacts==0.1.2
build as said on the homepage with
git clone https://github.com/sbarakat/beets-copyartifacts.git
cd beets-copyartifacts
python setup.py install

, but this does not copy the plugin to /usr/lib/python3.6/site-packages/beetsplug
so i copied it to /home/user/Musik/beets/
and made an entry in config.yaml
pluginpath: /home/user/Musik/beets

when i try to import a directory with following content (just because it's so short):
'01 - Flava (Radio 7 Edit) - Peter Andre.ogg'
'02 - Flava (Benz Mix) - Peter Andre.ogg'
'03 - Flava (Richie P Mix) - Peter Andre.ogg'
'04 - Flava (Crichton & Morris 12 Mix) - Peter Andre.ogg'
'Peter Andre - Flava.ogg.m3u'
cover.jpg

i get the following error

Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/beets/plugins.py", line 124, in wrapper
return func(*args, **kwargs)
TypeError: process_events() got an unexpected keyword argument 'lib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/bin/beet", line 11, in
load_entry_point('beets==1.4.3', 'console_scripts', 'beet')()
File "/usr/lib/python3.6/site-packages/beets/ui/init.py", line 1209, in main
_raw_main(args)
File "/usr/lib/python3.6/site-packages/beets/ui/init.py", line 1198, in _raw_main
plugins.send('cli_exit', lib=lib)
File "/usr/lib/python3.6/site-packages/beets/plugins.py", line 452, in send
result = handler(**arguments)
File "/usr/lib/python3.6/site-packages/beets/plugins.py", line 130, in wrapper
return func(*args, **kwargs)
File "/home/daniel/Musik/beets/copyartifacts.py", line 127, in process_events
self.process_artifacts(item['files'], item['mapping'], False)
File "/home/daniel/Musik/beets/copyartifacts.py", line 161, in process_artifacts
dest_file = beets.util.unique_path(dest_file)
File "/usr/lib/python3.6/site-packages/beets/util/init.py", line 512, in unique_path
match = re.search(br'.(\d)+$', base)
File "/usr/lib/python3.6/re.py", line 182, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a bytes pattern on a string-like object

right after selecting [A]pply in dialog.

AND THEN:
i have all the files doubled in the new location :(
and the "artifacts" are missing :-((

'01 Flava (Radio 7_ Edit).ogg'
'01 - Flava (Radio 7 Edit) - Peter Andre.ogg'
'02 Flava (Benz Mix).ogg'
'02 - Flava (Benz Mix) - Peter Andre.ogg'
'03 Flava (Richie P Mix).ogg'
'03 - Flava (Richie P Mix) - Peter Andre.ogg'
'04 - Flava (Crichton & Morris 12 Mix) - Peter Andre.ogg'
'04 Flava (Crichton & Morris 7_ Mix).ogg'
cover.jpg

what did i do wrong?

CopyArtifacts behaving badly with the 'Use as is' auto-tagger option

I think CopyArtifacts may be behaving badly when using the 'Use as is' auto-tagger option when beets is set to move files during import. It cause beets to crash. I think it might be because the 'Use as is' option moves the folder in the source directory, renaming it and putting it in the destination directory in the folder '_'. Whereas normally beets would create a new folder in the destination with the pathname specified in the config.yaml ($albumartist_sort/$album%aunique{} etc.). Since it moves the folder when using 'Use as is' there is no folder to copy artifacts from. But that just my theory.... here's what I get for output when it crashes.

Traceback (most recent call last):
File "/usr/local/bin/beet", line 8, in <module>
load_entry_point('beets==1.3.3', 'console_scripts', 'beet')()
File "/Library/Python/2.7/site-packages/beets-1.3.3-py2.7.egg/beets/ui/__init__.py", line 946, in main
_raw_main(args)
File "/Library/Python/2.7/site-packages/beets-1.3.3-py2.7.egg/beets/ui/__init__.py", line 937, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/Library/Python/2.7/site-packages/beets-1.3.3-py2.7.egg/beets/ui/commands.py", line 843, in import_func
import_files(lib, paths, query)
File "/Library/Python/2.7/site-packages/beets-1.3.3-py2.7.egg/beets/ui/commands.py", line 779, in import_files
session.run()
File "/Library/Python/2.7/site-packages/beets-1.3.3-py2.7.egg/beets/importer.py", line 347, in run
pl.run_parallel(QUEUE_SIZE)
File "/Library/Python/2.7/site-packages/beets-1.3.3-py2.7.egg/beets/util/pipeline.py", line 243, in run
out = self.coro.send(msg)
File "/Library/Python/2.7/site-packages/beets-1.3.3-py2.7.egg/beets/importer.py", line 905, in manipulate_files
plugins.send('import_task_files', session=session, task=task)
File "/Library/Python/2.7/site-packages/beets-1.3.3-py2.7.egg/beets/plugins.py", line 372, in send
handler(**arguments)
File "/Library/Python/2.7/site-packages/copyartifacts-0.2-py2.7.egg/beetsplug/copyartifacts.py", line 27, in add_artifacts
for filename in os.listdir(task.paths[0]):
OSError: [Errno 2] No such file or directory: '/Volumes/MUSIC/MusicTmp/Fruition/Fruition'

I can't manage to make it work

Hi,

I think that I have done the installation properly, but I always have this error messaeg

** error loading plugin copyartifacts:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/beets/plugins.py", line 270, in load_plugins
namespace = import(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.copyartifacts'

Any help ?

thansk a lot !

copyartifacts ignoring files

I'm trying to import a FLAC album, below my configuration:

paths:
    ext:log: $albumpath/$album%if{$multidisc, - Disc $disc}
    ext:cue: $albumpath/$album%if{$multidisc, - Disc $disc}
    ext:jpg: $albumpath/original_cover

item_fields:
    multidisc: 1 if disctotal > 1 else 0

copyartifacts:
    extensions: .cue .log .jpg
    print_ignored: yes

And here the output of an example import:

$ beet import Yeezus\ -\ Kanye\ West\ \[2013\]\ \(FLAC\)/

/downloads/music/mutracker/Yeezus - Kanye West [2013] (FLAC) (10 items)
Tagging:
    Kanye West - Yeezus
URL:
    https://musicbrainz.org/release/d607b7f8-9d2f-4387-be7c-0693d185d272
(Similarity: 100.0%) (CD, 2013, GB, Def Jam Recordings)
 * I Am A God (feat. God) -> I Am a God (feat. God)
 * I'm In It              -> I'm in It
 * Blood On The Leaves    -> Blood on the Leaves
copyartifacts: Ignored files:
copyartifacts:    02 - Black Skinhead.flac
copyartifacts:    03 - I Am A God (feat. God).flac
copyartifacts:    04 - New Slaves.flac
copyartifacts:    05 - Hold My Liquor.flac
copyartifacts:    06 - I'm In It.flac
copyartifacts:    07 - Blood On The Leaves.flac
copyartifacts:    08 - Guilt Trip.flac
copyartifacts:    09 - Send It Up.flac
copyartifacts:    10 - Bound 2.flac
copyartifacts:    Kanye West - Yeezus [2013].cue
copyartifacts:    Kanye West - Yeezus.jpg
copyartifacts:    Kanye West - Yeezus.log
copyartifacts:    Kanye West - Yeezus.m3u

What am I missing?

@Stunner, I've seen your comment on beetbox/beets#111 and I was wondering if maybe it's something in my config that's causing issues.

Crash on beet import --group-albums

Traceback (most recent call last):
File "/usr/local/bin/beet", line 9, in
load_entry_point('beets==1.3.4', 'console_scripts', 'beet')()
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/ui/init.py", line 953, in main
_raw_main(args)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/ui/init.py", line 944, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/ui/commands.py", line 847, in import_func
import_files(lib, paths, query)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/ui/commands.py", line 783, in import_files
session.run()
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/importer.py", line 347, in run
pl.run_parallel(QUEUE_SIZE)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/util/pipeline.py", line 243, in run
out = self.coro.send(msg)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/importer.py", line 905, in manipulate_files
plugins.send('import_task_files', session=session, task=task)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/plugins.py", line 372, in send
handler(**arguments)
File "/usr/local/lib/python2.7/dist-packages/copyartifacts-1.0_beta.1-py2.7.egg/beetsplug/copyartifacts.py", line 73, in add_artifacts
for filename in os.listdir(task.paths[0]):
TypeError: 'NoneType' object has no attribute 'getitem'

crash copying artifacts with invalid characters

beets-copyartifacts crashes when copying artifacts that have invalid characters. This only occurs if a path renaming is required and the albumartist or album have invalid characters in the tags.

config file:

    ext:log: $albumpath\$albumartist - $album
    ext:LOG: $albumpath\$albumartist - $album
    ext:cue: $albumpath\$albumartist - $album
    ext:CUE: $albumpath\$albumartist - $album
    ext:pdf: $albumpath\$albumartist - $album
    ext:PDF: $albumpath\$albumartist - $album
    ext:nfo: $albumpath\$albumartist - $album
    ext:NFO: $albumpath\$albumartist - $album

The example of an error below is quite lengthy, but it is the ? at the end of the path that is causing the issue. I had the same with "De La Soul - It ain't all good?", but not with any other releases.

Error: invalid mode ('wb') or filename while copying \\?\d:\Downloads\utorrent\complete E-J\George Clinton & The P-Funk All-Stars - How Late Do U Have 2BB4UR Absent (2005) [FLAC]\Disc 1\How Late Do U Have 2BB4UR Absent.cue to \\?\E:\Audio\beets\FLAC\G\George Clinton Presents P-Funk All Stars\[2005] How Late Do U Have 2BB4UR Absent_\George Clinton Presents P-Funk All Stars - How Late Do U Have 2BB4UR Absent?.cue

Should be straightforward to replicate. If needed, I can also provide files. Seems to me beets-copyartifacts needs to apply the same character-replacement as beets does.

The plugin does not replace "illegal" characters.

When copying files via this plugin, it does not replace "illegal" characters.
If I as an example run this plugin on the album "TRON: Legacy", and use the format $albumpath/$artist - $album, it does not replace the ':' sign.
It should reference the replace section that beets uses, or change this by itself.

eg: MUSIC/Hans Zimmer/[2014] - Interstellar_ Original Motion Picture Soundtrack [FLAC]/Hans Zimmer - Interstellar: Original Motion Picture Soundtrack.1.cue
Notice the ':' sign at the cue-file.

Add support for multiple discs

I have used your plugin to copy artefacts with the music files. While testing and optimizing my configuration, I finally encountered a problem.

Parts of my beets.conf

per_disc_numbering: yes

paths:
default: Music/Album/$albumartist/[$year] $album%aunique{}%if{$isMultiDisc,/CD $disc}/$track. $title
item_fields:
isMultiDisc: u'yes' if
disctotal > 1 else u''

copyartifacts:
extensions: .*
print_ignored: yes

When I import an album that contains of two disks, the artefacts of both discs end up in one of the subfolders. I tried it many time and it is not consistend in which of the CD XX folders they end up.

When Selecting "R" for 'Remove old', the folder still remains

When re-importing the same items (so that minor tweaks to the import are implemented in the output folder), selecting "R" for 'Remove old,' does not delete folders that were originally created because the copied artifacts are still in the original destination folder.

To re-create the issue:

  1. Import and folder with additional image files.
  2. Change the path rule in the Beets config file 'config.yaml' (in my case, to create buckets for $albumartist, 'A," 'B,' 'C,' etc...).
  3. Import the item again and select 'R,' when prompted.

You will see that the original files created by Beets were deleted from the folder, but the artifact files remain in the folder, and the folder is not deleted.

Small issue, overall. Thanks for the plug-in! It does a great job from what I am seeing so far!

pyton 3

In python3 i get the following error, when using beets

error loading plugin copyartifacts:
Traceback (most recent call last):
File "/opt/local/lib/python3.7/site-packages/beets/plugins.py", line 273, in load_plugins
namespace = import(modname, None, None)
File "/opt/local/lib/python3.7/site-packages/beetsplug/copyartifacts.py", line 141
print 'Ignored files:'

This is showing on every command i do with beet

copyartifacts fights with fetchart for local cover art images

fetchart can find covers in the local directory of the album, by looking for *.jpg files. It does this during the early part of the import, and then copies the file to its new name after all the file copies have happened.

With copyartifacts in place, that file isn't there any more by the time fetchart comes to copy it!

Moving artifact: 00-amon_tobin-out_from_out_where.m3u
Moving artifact: 00-amon_tobin-out_from_out_where.sfv
Moving artifact: folder.jpg
Error: No such file or directory while moving /mnt/music/Incoming/Amon Tobin/Amon Tobin - Out From Out Where [2002]/folder.jpg to /mnt/music/Cleaned/SingleArtist/Amon Tobin/Amon Tobin - Out From Out Where [2002]/cover.jpg

Error when '/' in $artist, possibly other characters too.

It appears that copyartifacts is not replacing characters as beets does by default. http://beets.readthedocs.org/en/1.0b15/reference/config.html#replace See the message below where beets has renamed AC/DC to AC_DC, but copyartifacts is trying to rename the .hash file with the 'slash' in the band's name. Of course this won't work as the path doesn't exist.

This issue might exist for other 'unexpected' characters as well (see the link above), but I haven't tried.

Moving artifact: DC - Dirty Deeds Done Dirt Cheap.hash
Error: No such file or directory while moving '/volume1/music/flac/ACDC/Dirty Deeds Done Dirt Cheap/Dirty Deeds Done Dirt Cheap.hash' to u'/volume1/music/music/AC_DC/Dirty Deeds Done Dirt Cheap/AC/DC - Dirty Deeds Done Dirt Cheap.hash'

copyartifacts stops copying when it throws exception

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\beets\plugins.py", line 124, in wrapper
    return func(*args, **kwargs)
TypeError: process_events() got an unexpected keyword argument 'lib'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python36-32\Scripts\beet-script.py", line 11, in <module>
    load_entry_point('beets==1.4.5', 'console_scripts', 'beet')()
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\beets\ui\__init__.py", line 1256, in main
    _raw_main(args)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\beets\ui\__init__.py", line 1245, in _raw_main
    plugins.send('cli_exit', lib=lib)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\beets\plugins.py", line 452, in send
    result = handler(**arguments)
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\beets\plugins.py", line 130, in wrapper
    return func(*args, **kwargs)
  File "c:\program files (x86)\python36-32\lib\site-packages\beets_copyartifacts-0.1.2-py3.6.egg\beetsplug\copyartifacts.py", line 127, in process_events
  File "c:\program files (x86)\python36-32\lib\site-packages\beets_copyartifacts-0.1.2-py3.6.egg\beetsplug\copyartifacts.py", line 161, in process_artifacts
  File "C:\Program Files (x86)\Python36-32\lib\site-packages\beets\util\__init__.py", line 536, in unique_path
    match = re.search(br'\.(\d)+$', base)
  File "C:\Program Files (x86)\Python36-32\lib\re.py", line 182, in search
    return _compile(pattern, flags).search(string)
TypeError: cannot use a bytes pattern on a string-like object
PS C:\Users\james>

crash on track import

importing a folder with just some singles, identifying by track, not album:

Traceback (most recent call last):
File "/usr/local/bin/beet", line 9, in
load_entry_point('beets==1.3.4', 'console_scripts', 'beet')()
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/ui/init.py", line 953, in main
_raw_main(args)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/ui/init.py", line 944, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/ui/commands.py", line 847, in import_func
import_files(lib, paths, query)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/ui/commands.py", line 783, in import_files
session.run()
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/importer.py", line 347, in run
pl.run_parallel(QUEUE_SIZE)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/util/pipeline.py", line 243, in run
out = self.coro.send(msg)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/importer.py", line 905, in manipulate_files
plugins.send('import_task_files', session=session, task=task)
File "/usr/local/lib/python2.7/dist-packages/beets-1.3.4-py2.7.egg/beets/plugins.py", line 372, in send
handler(**arguments)
File "/usr/local/lib/python2.7/dist-packages/copyartifacts-1.0_beta.1-py2.7.egg/beetsplug/copyartifacts.py", line 66, in add_artifacts
'artist': task.cur_album,
AttributeError: 'ImportTask' object has no attribute 'cur_album'

Plugin incorrectly moves files on resumed import (reimport) even when move is disabled.

I have the following config (snippet):

import:
    move: no
    copy: yes
    write: yes

copyartifacts:
    extensions: .*
    print_ignored: yes

Which should only copy files, which works perfectly fine,
unless I resume a previously interrupted import.
When I do that, it moves the files instead of copying them.

Edit:
After further investigation, it seems it does copy some artifacts, but others it only moves.

Edit2:

if config['import']['move']:
self._move_artifact(source_file, dest_file)
else:
if reimport:
# This is a reimport
# files are already in the library directory
self._move_artifact(source_file, dest_file)
else:
# A normal import, just copy
self._copy_artifact(source_file, dest_file)

This code seems to be responsible.
I don't completely understand this, but I set up beets to never move any of my source files, and this clearly does the opposite of that. And it seems like this plugin interprets the resumed import as a reimport and just moves the files, even if the config clearly states to never move any files.

SyntaxError: Missing parentheses in call to 'print'_

hi

running bees 1.4.3 , python 3.6.1 on a raspberry pi3, raspbian jessie(light). i'm getting these errors:
** error loading plugin copyartifacts:
Traceback (most recent call last):

File "/usr/local/lib/python3.6/site-packages/beets/plugins.py", line 254, in load_plugins
namespace = import(modname, None, None)
File "/usr/local/lib/python3.6/site-packages/beetsplug/copyartifacts.py", line 141
print 'Ignored files:'
^
SyntaxError: Missing parentheses in call to 'print'

any idea?
best regards

beets modify is not moving artifacts

When I use

beets modify -w ...

and the changes result in beets moving the files to a different directory, this plugin does not move the artifacts with it.

Exception when copying files

I saw this exception at the end of a beet import job, and none of the expected artifacts got copied:

Traceback (most recent call last):
  File "/home/sam/.local/bin/beet", line 11, in <module>
    load_entry_point('beets==1.4.7', 'console_scripts', 'beet')()
  File "/home/sam/.local/lib/python3.6/site-packages/beets/ui/__init__.py", line 1256, in main
    _raw_main(args)
  File "/home/sam/.local/lib/python3.6/site-packages/beets/ui/__init__.py", line 1245, in _raw_main
    plugins.send('cli_exit', lib=lib)
  File "/home/sam/.local/lib/python3.6/site-packages/beets/plugins.py", line 476, in send
    result = handler(**arguments)
  File "/home/sam/.local/lib/python3.6/site-packages/beets/plugins.py", line 140, in wrapper
    return func(*args, **kwargs)
  File "/home/sam/.local/lib/python3.6/site-packages/beetsplug/copyartifacts.py", line 127, in process_events
    self.process_artifacts(item['files'], item['mapping'], False)
  File "/home/sam/.local/lib/python3.6/site-packages/beetsplug/copyartifacts.py", line 161, in process_artifacts
    dest_file = beets.util.unique_path(dest_file)
  File "/home/sam/.local/lib/python3.6/site-packages/beets/util/__init__.py", line 548, in unique_path
    match = re.search(br'\.(\d)+$', base)
  File "/usr/lib64/python3.6/re.py", line 182, in search
    return _compile(pattern, flags).search(string)
TypeError: cannot use a bytes pattern on a string-like object

bug *fix* (with code): Files not copying for dir's that contain ASCII on windows fs

Hi,
Firstly thanks for the great plugin. Certainly an essential addon for beets!
I found a bug in your code however that was giving me crashes when it attempted to copy files to/from dir's that contained ascii chars.

My traceback:

Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\beet.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\beets\ui\__init__.py", line 1236, in main
    _raw_main(args)
  File "c:\python27\lib\site-packages\beets\ui\__init__.py", line 1226, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "c:\python27\lib\site-packages\beets\ui\commands.py", line 966, in import_func
    import_files(lib, paths, query)
  File "c:\python27\lib\site-packages\beets\ui\commands.py", line 943, in import_files
    session.run()
  File "c:\python27\lib\site-packages\beets\importer.py", line 321, in run
    pl.run_parallel(QUEUE_SIZE)
  File "c:\python27\lib\site-packages\beets\util\pipeline.py", line 348, in run
    self.coro.send(msg)
  File "c:\python27\lib\site-packages\beets\util\pipeline.py", line 161, in coro
    task = func(*(args + (task,)))
  File "c:\python27\lib\site-packages\beets\importer.py", line 1397, in manipulate_files
    session=session,
  File "c:\python27\lib\site-packages\beets\importer.py", line 689, in manipulate_files
    plugins.send('import_task_files', session=session, task=self)
  File "c:\python27\lib\site-packages\beets\plugins.py", line 459, in send
    result = handler(**arguments)
  File "c:\python27\lib\site-packages\beets\plugins.py", line 124, in wrapper
    return func(*args, **kwargs)
  File "c:\python27\lib\site-packages\beetsplug\copyartifacts.py", line 122, in add_artifacts
    and filecmp.cmp(source_file, dest_file)):
  File "c:\python27\lib\filecmp.py", line 42, in cmp
    s1 = _sig(os.stat(f1))
WindowsError: [Error 3] The system cannot find the path specified: 'Z:\\Sleep \xe2\x88\x9e Over - Forever (2011)\\cover.jpg'

Duplicates can get created on move

When running beet move on an already imported directory with multiple artifacts the plugin can cause duplicates to be created if beet move is run multiple times.

config.yml

paths:
    default: $albumartist/$disc_and_track - $title
    ext:txt: $albumpath/$album

Original state

album/track1.mp3
album/file1.txt
album/file2.txt

After beet import

album/01 - track1.mp3
album/album.txt
album/album.1.txt

After beet move

album/01 - track1.mp3
album/album.txt
album/album.1.txt
album/album.2.txt    # duplicate of album.1.txt

This is caused by a combination of the mappings and the unique file naming algorithm. After import album.1.txt gets its name due to album.txt already being taken and is a different file. After move, a similar thing happens, however only file name existence is checked and a comparison of file content is done done after the first iteration.

artifacts are not copied when using beet mod

If you use beet mod, some files can be potentially moved.

For instance, given these two configured paths:

paths:
default: _trier/$albumartist/$albumartist - $year - $album/$disc_and_track. $title
savedir: metal: metal_hard-rock/$albumartist/$albumartist - $year - $album/$disc_and_track. $tit

And then typing this command:

beet mod savedir=metal artist:Metallica

Beets will add the "savedir" field in the matching files, and put the "metal" value in it. Since there's a path directive that matches this, beets will also move the files to te "metal_hard-rock" directory. But it seems that copyartifact doesn't hook to that function because the artifacts I've defined (*.cue and *.log) for instance will not be copied, and instead will stay in the "_trier" directory.

For reference, this is my copyartifact section:

copyartifacts:
extensions: .cue .log folder.jpg folder.png Folder.jpg folder.png

Maybe I'm doing something wrong, but the artifacts seem properly moved upon import - just not when using "modify."

Getting a Namspace error when attempting installation

I'm trying to get copy-artifacts installed on my new pc. I had it working on my old pc. But when I try to run the setup.py I get this error.

error: Namespace package problem: beetsplug is a namespace package, but its
__init__.py does not call declare_namespace()! Please fix it.
(See the setuptools manual under "Namespace Packages" for details.)

It looks like someone else was having this issue but posted it to the beets issue board here but it doesn't look like it got resolved.

option for no output

Hi,

I've been using copy-artifacts, works like a charm. So much so that I trust it enough to not need the output for every successful copy. Thing is, this output often disturbs the regular output of beets, making it a lot more difficult to go through the importer.
Would it be possible to add an option, similar to the print_ignored option, that also allows the choice to have regular output, or more importantly, no output at all? Maybe print_successful?

thx!

Support for link and hardlink beets options

It looks like the plugin has no support for the link and hardlink beets config options, so does not behave properly when those options are in effect rather than copy or move.

plugin failing

Hi,

Thanks for the plugin, I'm having trouble getting it to work.
I am getting this error:

Traceback (most recent call last):
  File "/usr/local/bin/beet", line 9, in <module>
    load_entry_point('beets==1.1.0-beta.1', 'console_scripts', 'beet')()
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 725, in main
    _raw_main(args)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 718, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 684, in import_func
    import_files(lib, paths, query)
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/commands.py", line 624, in import_files
    session.run()
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 336, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/local/lib/python2.7/dist-packages/beets/util/pipeline.py", line 243, in run
    out = self.coro.send(msg)
  File "/usr/local/lib/python2.7/dist-packages/beets/importer.py", line 854, in manipulate_files
    plugins.send('import_task_files', session=session, task=task)
  File "/usr/local/lib/python2.7/dist-packages/beets/plugins.py", line 311, in send
    handler(**arguments)
  File "/usr/local/lib/python2.7/dist-packages/copyartifacts-0.2-py2.7.egg/beetsplug/copyartifacts.py", line 27, in add_artifacts
    for filename in os.listdir(task.paths[0]):
AttributeError: 'ImportTask' object has no attribute 'paths'

My config:

directory: ~/Music
library: ~/.config/beets/library.blb

import:
    move: yes
    log: beetslog.txt
color: yes


paths:
    default: $albumartist/$year - $album%aunique{}/$track - $title
    singleton: Non-Album/$artist/$title
    comp: "Various Artists/$album%aunique{}/$track - $title"


copyartifacts:
    extensions: .*


#plugins: lyrics fetchart chroma info fuzzy lastgenre
plugins: copyartifacts

Plugin moves wrong files

Hi!

I found a strange behaviour while using copyartifacts. Imagine the following situation before importing:

library/title.mp3
library/artist/track1.mp3
library/artist/track2.mp3
library/artist/track3.mp3
library/artist/cover.jpg

The paths are configured such singletons are moved into a folder called misc at the library root hence the title.mp3 will be moved while importing. Doing so leads to the following situation:

library/artist/track1.mp3
library/artist/track2.mp3
library/artist/track3.mp3
library/misc/title.mp3
library/misc/artist/cover.jpg

So the cover gets moved into the misc folder, too.

After digging a bit through the code I found the reason for this behaviour: It searches recursively for files to move. Since title.mp3 is moved, the plugin finds cover.jpg in the sub folder.

I'm not sure if this will only happen for my special situation here or if it might bite others, too. I'm also unsure how to solve this. Basically, I see two possibilities:

  1. Add a config option to turn off recursive search.
  2. Only search recursively until there is a file which might be handled by beets inside the child folders.

Any thoughts about it?

copyartifacts not working with mbsync

I'm not sure where the problem lies here, but if an album is moved as a result of using the mbsync plugin, it seems that copyartifacts is not invoked, leaving us with a whole bunch of orphaned files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.