Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy and rewrite (edit to point to the new files) m3u playlists #116

Open
quantenzitrone opened this issue Dec 15, 2024 · 9 comments
Open

Comments

@quantenzitrone
Copy link

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.

@geigerzaehler
Copy link
Owner

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.

@quantenzitrone
Copy link
Author

  1. i use the playlist plugin to automatically rewrite the paths in playlists if the directory structure changes.
  2. 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)"
  1. The playlists are located in the root music directory.
  2. 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.

@geigerzaehler
Copy link
Owner

Thanks for the info. If I understand this correctly, after running beet alt update you want the following

  1. For every playlist you specified (“Calm Vocals“, etc.) there should be a corresponding playlist in /data/music/opusmusic/playlists.
  2. 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.

  1. Users want to configure the directory where playlists are written.
  2. 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.
  3. Do we want to remove playlists from the alternatives that are not explicitly specified? Probably
  4. 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?

@quantenzitrone
Copy link
Author

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.

@geigerzaehler
Copy link
Owner

Sure, I can try to implement it.

Cool! Take a look at DEVELOPING.md and let me know if you need support.

@sindreruud
Copy link

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.

@geigerzaehler
Copy link
Owner

I would definitely use a feature like this!

Glad to here that. To summarize your use case:

  1. You specify the location of your playlists, for example with a glob playlists/*
  2. alt update copies all playlists matching the glob (e.g. playlists/all.m3u) to the alternative directory (e.g. $ALT_DIR/playlists/all.m3u).
  3. The playlists items point to items in the alt directory. Any items not included are removed from the playlist copy

@sindreruud
Copy link

sindreruud commented Jan 20, 2025

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.

@quantenzitrone
Copy link
Author

i havent started yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants