copy and rewrite (edit to point to the new files) m3u playlists
I manage the music i listen to in m3u playlist files, so when i create an alternative folder with all my music transcoded to opus so it fits on my phone, i also want my playlists copied. Right now i have to do that manually.
Hi @quantenzitrone. To get a better idea of your use case I have a couple of questions:
Are you using any of the beets playlist plugins to manage your playlists? Could you share your configuration? Where are the playlists located? Are you using a different file structure for your alternative folder?
I guess the main challenge in designing this feature will be figuring out how it works with playlist plugins and queries. If you have any suggestions feel free to post them.
- i use the playlist plugin to automatically rewrite the paths in playlists if the directory structure changes.
- sure:
beets config (without the secrets obviously)
replace: {
# slashes
"/": "⧸",
# dots at the beginning (so files are not hidden)
'^\.': "․",
# remove ascii control characters
'[\x00-\x1f]': "_",
# spaces at the beginning and and
'\s+$': "",
'^\s+': "",
# dash at the beginning (to not break dumbly programmed commandline tools)
"^-": "_",
# russian А to latin A so i can shell complete Aмура
"А": "A",
}
path_sep_replace: "⧸"
paths:
default: '%first{$albumartists,1,0,\␀}/$album [$year]/$track - $title'
singleton: '%first{$artists,1,0,\␀}/Tracks/$title'
comp: "Compilations/$album [$year]/$track - $title"
albumtype:single: '%first{$artists,1,0,\␀}/Singles/$title [$year]'
match:
preferred:
countries: ["XW", "XE"]
media: ["Digital Media"]
original_year: true
max_rec:
chroma: high
chroma:
auto: true
plugins:
[
unimported,
bareasc,
fish,
badfiles,
duplicates,
albumtypes,
chroma,
lyrics,
embedart,
fetchart,
playlist,
mbsync,
info,
advancedrewrite,
scrub,
mbcollection,
replaygain,
play,
alternatives,
convert,
checkplaylist,
substitute,
]
# additionally remove all characters that dont work on fat32
substitute:
'["*/:<>?\|+,\.;=!@]|\]|\[' : '_'
alternatives:
opus:
directory: /data/music/opusmusic
formats: opus
paths:
default: '%if{$mb_trackid,$mb_trackid,no-mbid/%lower{%left{$acoustid_fingerprint,50}}}'
query: "
playlist:'Calm Vocals',
playlist:'Cyberphonk',
playlist:'Heavy Trap',
playlist:'Metal',
playlist:'Novah',
playlist:'Trip In Multiverse',
playlist:'Rap',
playlist:'Sad Rap'
"
removable: false
convert:
formats:
opus: "/data/music/__bin/convert-to-opus.fish $source $dest"
play:
command: mpv
replaygain:
backend: ffmpeg
overwrite: true
# YouTube, Spotify, Tidal and Amazon normalize to -14 LUFS -> 93 db
targetlevel: 93
r128_targetlevel: 93
musicbrainz:
genres: true
playlist:
auto: true
playlist_dir: /data/music/hqmusic
unimported:
ignore_extensions: [
# ignore lyrics files
lrc,
txt,
# ignore playlists
m3u,
# ignore additional metadata files
rss,
norss,
# ignore images
jpg,
jpeg,
png,
]
badfiles:
check_on_import: true
commands:
opus: opusinfo
ogg: ogginfo
lyrics:
synced: true
fetchart:
sources:
- coverart: release
high_resolution: true
embedart:
remove_art_file: true
advancedrewrite:
- match: mb_albumid:"4015a325-5dee-4562-870e-f63c648931b9"
replacements:
album: "Happier Than Ever (edit)"
- The playlists are located in the root music directory.
- My alternate folder uses a different file structure, because android is dumb and doesn't permit all the special characters that are allowed on ext4 or similarly modern linux file systems. The paths also change because i convert the music to opus.
Thanks for the info. If I understand this correctly, after running beet alt update you want the following
- For every playlist you specified (“Calm Vocals“, etc.) there should be a corresponding playlist in
/data/music/opusmusic/playlists. - Every item in the original playlist has a corresponding item in the new playlist which points to the path in the alternative collection
Is this correct?
There‘s a few things we need to consider to get this feature right.
- Users want to configure the directory where playlists are written.
- Users want to configure which playlists are included. Just listing all the names is a good starting point but we might want something more advanced down the line.
- Do we want to remove playlists from the alternatives that are not explicitly specified? Probably
- Should we include items in the playlists that are not themselves in the alternative collection? Probably not, we should remove the
Do my assumptions seem reasonable? Is there anything missing?
Finally, are you interested in implementing this feature @quantenzitrone?
Correct, reasonable and nothing missing i can think of. Sure, I can try to implement it. I have already dabbled a bit with custom beets plugins for my local music collection.
Sure, I can try to implement it.
Cool! Take a look at DEVELOPING.md and let me know if you need support.
This sounds amazing and I would definitely use a feature like this!
My use case is slightly different, but I still think it fits with the outlined features over.
My alternatives library has the exact same structure as my main one, only difference is that the file ending is .aiff instead of .flac. It also does not contain as many songs as the main one.
I use both the beets playlists and smart-playlists plugins, and I would very much like these playlists to be included when i do "beet alt update".
Since there would be certain songs in the playlists not present in the alternative library, these would probably need to be removed from the "alternatives playlist" when it gets sent over.
I would definitely use a feature like this!
Glad to here that. To summarize your use case:
- You specify the location of your playlists, for example with a glob
playlists/* alt updatecopies all playlists matching the glob (e.g.playlists/all.m3u) to the alternative directory (e.g.$ALT_DIR/playlists/all.m3u).- The playlists items point to items in the alt directory. Any items not included are removed from the playlist copy
You specify the location of your playlists, for example with a glob playlists/*
Sounds reasonable. We would need to specify if the playlists needs to have relative paths or absolute paths, or if both should be supported. For mye use-case, I would need absolute paths.
alt update copies all playlists matching the glob (e.g. playlists/all.m3u) to the alternative directory (e.g. $ALT_DIR/playlists/all.m3u).
Sounds good! Would be nice to have that in the config, like
alternatives:
myplayer:
directory: /player
playlists: /player/playlists
edit: come to think of it, we would need to have both the "main-library" playlist folder and the "alternatives-library" folder path for the playlists, in the config.
The playlists items point to items in the alt directory. Any items not included are removed from the playlist copy
Sounds good!
@quantenzitrone, did you have a chance to look into this? I would be happy to test this and help where I can.
i havent started yet
This feature would be great! I currently have a shell script to do this in my instance, but if it's built into the plugin it would be much better workflow.
I basically copy all the files in my beets library playlist directory to the alternative library playlist directory, and run sed --in-place 's|\.flac$|.opus|' but this is suited to my usecase where my library is all flac files and the alternative is a subset of my library transcoded to opus.
If nobody's started this yet, I'll pick up this issue. Would love to easily sync my playlists between my computer and iPod with this plugin :D
- Do we want to remove playlists from the alternatives that are not explicitly specified? Probably
Given my usecase is an iPod running Rockbox, I may do something extra with this. Sometimes I'll build a playlist on my iPod, and I'll want that on my PC. I agree that this should be default behavior, but I may dabble with creating a CLI option that lets users "rip" playlists from their iPod to their machine.