Giter Site home page Giter Site logo

beets-navidrome_sync's Introduction

beets-navidrome_sync

Work in progress syncing plugin between beets and Navidrome, works well enough for my own use on Windows, needs testing on *nix.

So far, it can do the following:

  • Recursively scan your music folder, grab all the modified (or created (on Windows only apparently??)) timestamps, and update your Navidrome Created/Updated times to these dates, i.e. set your 'Recently added' order to that of file creation
  • will modfiy a local navidrome.db file, or connect over SFTP and download a copy to modify as well (works well with Pikapods)
  • 2 way syncing - either push, or pull annotations (starred, play counts, ratings) between Navidrome and beets
  • Push MusicBrainz metadata into the Navidrome DB
  • Will attempt to match tracks by a few means, either by MusicBrainz track ID, path, artist & title, or if all else fails, will try a sort of fuzzy search which matches individual segments of the artist, title, and album to the 'full_text' field in Navidrome's DB, as a result matching success is quite high from initial tests.
  • Upload files to your remote SFTP storage directly from the beets prompt as well as automatically upload items following their import to the library.

Here's some crap documentation because I'm lazy, courtesy of Copilot (edited somewhat for clarification in parts)

Installation

  1. Install Beets by following the instructions on the Beets website.

  2. Install the pysftp and tqdm Python packages by running pip install pysftp tqdm.

  3. Clone this repository or download the ZIP file and extract it to a directory of your choice.

  4. Copy the navidrome_sync directory to your beetsplug directory.

  5. Edit your Beets configuration file (~/.config/beets/config.yaml) and add the following lines :

    plugins: navidrome_sync
    
    navidrome_sync:
      dbpath: /path/to/local/navidrome.db
      dbuser: your-db-username # not necessarily your navidrome login username, for syncing stars/ratings to the right user
    
    # optional:
      pushtarget : local # can be 'local' (default), 'sftp', 'remote', or 'both' (sftp/remote are the same for now)
      navidrome:
        host: your-navidrome-server.com
        username: your-navidrome-username
        password: your-navidrome-password
      sftp:
        auto: no # default 'no', whether to auto-upload on import (probably not recommended to do your whole db at once with this)
        host: your-sftp-server.com
        username: your-sftp-username
        password: your-sftp-password
        directory: /path/to/remote/music_directory

    Replace the paths and values with your own Navidrome and SFTP server details.

Usage

Once you have installed and configured the plugin, you can use the following commands to sync your Beets library with Navidrome and upload your music files to the remote SFTP server:

  • beet ndpull: pull in annotation data (ratings and starred tracks) to the beets db, they'll be appeneded to a 'rating' and 'starred' field respectively. No real options for this yet.

  • beet ndpush: push annotation data and MusicBrainz data to the Navidrome DB The ndpush command of the NavidromeSyncPlugin has several command line options that you can use to customize its behavior.

Available options for ndpush:

  • -t, --time: Push directory file times to Navidrome database. This option is disabled by default.
  • -c, --ctime: Additional option for --time, uses created time (on Windows) rather than modified time.
  • -b, --mb: Push MusicBrainz data from Beets to Navidrome database. This option is enabled by default.
  • -B, --no-mb: Don't push MusicBrainz data from Beets to Navidrome database.
  • -s, --starred: Push starred tracks to Navidrome database. This option is enabled by default.
  • -S, --no-starred: Don't push starred tracks to Navidrome database.
  • -p, --playcounts: Push play counts to Navidrome database. This option is enabled by default.
  • -P, --no-playcounts: Don't push play counts to Navidrome database.
  • -r, --ratings: Push ratings to Navidrome database. This option is enabled by default.
  • -R, --no-ratings: Don't push ratings to Navidrome database.
  • -l, --log: Log missed items to file.
  • -A, --no-annotations: Don't update any annotations (play counts, ratings, starred, MusicBrainz data).

By default, ndpush will push MusicBrainz data, starred tracks, play counts, and ratings to the Navidrome database. You can use the --no-mb, --no-starred, --no-playcounts, and --no-ratings options to disable these features.

If you want to push directory file times to the Navidrome database, you can use the --time option. If you want to use the created time (on Windows) instead of the modified time, you can use the --ctime option.

If you want to log missed items to a file, you can use the --log option followed by the path to the log file.

For example, to push only play counts and ratings to the Navidrome database and log missed items to a file, you can use the following command:

beet ndpush -prBS --log /path/to/logfile.txt

If you want to disable all annotations (play counts, ratings, starred, MusicBrainz data), you can use the --no-annotations or -A option. Note that this option will override all other annotation-related options, for instance in cases where you only want to update the timestamps, e.g.:

beet ndpush -tcA

=======

beets-navidrome_sync

Work in progress syncing plugin between beets and Navidrome, works well enough for my own use on Windows, needs testing on *nix.

So far, it can do the following:

  • Recursively scan your music folder, grab all the modified (or created (on Windows only apparently??)), and update your Navidrome Created/Updated times to these dates, i.e. set your 'Recently added' order to that of file creation
  • will modfiy a local navidrome.db file, or (not fully implemented) connect over SFTP and download a copy to modify as well (works well with Pikapods)
  • 2 way syncing - either push, or pull annotations (starred, play counts, ratings) between Navidrome and beets
  • Push MusicBrainz metadata into the Navidrome DB
  • Will attempt to match tracks by a few means, either by MusicBrainz track ID, path, artist & title, or if all else fails, will try a sort of fuzzy search which matches individual segments of the artist, title, and album to the 'full_text' field in Navidrome's DB, as a result matching success is quite high from initial tests.
  • Upload files to your remote SFTP storage directly from the beets prompt as well as automatically upload items following their import to the library.

Here's some crap documentation because I'm lazy, courtesy of Copilot (edited somewhat for clarification in parts)

Installation

  1. Install Beets by following the instructions on the Beets website.

  2. Install the pysftp and tqdm Python packages by running pip install pysftp tqdm.

  3. Clone this repository or download the ZIP file and extract it to a directory of your choice.

  4. Copy the navidrome_sync directory to your beetsplug directory.

  5. Edit your Beets configuration file (~/.config/beets/config.yaml) and add the following lines :

    plugins: navidrome_sync
    
    navidrome_sync:
      dbpath: /path/to/local/navidrome.db
      dbuser: your-db-username # not necessarily your navidrome login username, for syncing stars/ratings to the right user
    
    # optional:
      pushtarget : local # can be 'local' (default), 'sftp', 'remote', or 'both' (sftp/remote are the same for now)
      navidrome:
        host: your-navidrome-server.com
        username: your-navidrome-username
        password: your-navidrome-password
      sftp:
        auto: no # default 'no', whether to auto-upload on import (probably not recommended to do your whole db at once with this)
        host: your-sftp-server.com
        username: your-sftp-username
        password: your-sftp-password
        directory: /path/to/remote/music_directory

    Replace the paths and values with your own Navidrome and SFTP server details.

Usage

Once you have installed and configured the plugin, you can use the following commands to sync your Beets library with Navidrome and upload your music files to the remote SFTP server:

  • beet ndpull: pull in annotation data (ratings and starred tracks) to the beets db, they'll be appeneded to a 'rating' and 'starred' field respectively. No real options for this yet.

  • beet ndpush: push annotation data and MusicBrainz data to the Navidrome DB The ndpush command of the NavidromeSyncPlugin has several command line options that you can use to customize its behavior.

Available options for ndpush:

  • -t, --time: Push directory file times to Navidrome database. This option is disabled by default.
  • -c, --ctime: Additional option for --time, uses created time (on Windows) rather than modified time.
  • -b, --mb: Push MusicBrainz data from Beets to Navidrome database. This option is enabled by default.
  • -B, --no-mb: Don't push MusicBrainz data from Beets to Navidrome database.
  • -s, --starred: Push starred tracks to Navidrome database. This option is enabled by default.
  • -S, --no-starred: Don't push starred tracks to Navidrome database.
  • -p, --playcounts: Push play counts to Navidrome database. This option is enabled by default.
  • -P, --no-playcounts: Don't push play counts to Navidrome database.
  • -r, --ratings: Push ratings to Navidrome database. This option is enabled by default.
  • -R, --no-ratings: Don't push ratings to Navidrome database.
  • -l, --log: Log missed items to file.
  • -A, --no-annotations: Don't update any annotations (play counts, ratings, starred, MusicBrainz data).

By default, ndpush will push MusicBrainz data, starred tracks, play counts, and ratings to the Navidrome database. You can use the --no-mb, --no-starred, --no-playcounts, and --no-ratings options to disable these features.

If you want to push directory file times to the Navidrome database, you can use the --time option. If you want to use the created time (on Windows) instead of the modified time, you can use the --ctime option.

If you want to log missed items to a file, you can use the --log option followed by the path to the log file.

For example, to push only play counts and ratings to the Navidrome database and log missed items to a file, you can use the following command:

beet ndpush -prBS --log /path/to/logfile.txt

If you want to disable all annotations (play counts, ratings, starred, MusicBrainz data), you can use the --no-annotations or -A option. Note that this option will override all other annotation-related options, for instance in cases where you only want to update the timestamps, e.g.:

beet ndpush -tcA

beets-navidrome_sync's People

Contributors

mcleodd10 avatar

Watchers

 avatar  avatar

beets-navidrome_sync's Issues

Some questions about the plugin

All of my files are in one big directory, and I'm planning on using the beets group option to finally group them into albums.
This will inevitably break my current Navidrome database.
So if I'm understanding what the plugin does correctly, I should be able to set up beets with my current directory and everything should continue to work.
To migrate I would need to:

  1. Use beet ndpull to embed all of my Navidrome data into the beets database.
  2. Rearrange all of my albums using the beets group option.
  3. Rescan the Navidrome database.
  4. The database breaks because the path change of all of my files.
  5. Use beet ndpush to push all of my previous Navidrome data from the beets database to the Navidrome database?

Write metadata to files

Do you have any plans on bypassing beets completely and writing the metadata from Navidrome to files directly?

Error: unknown command 'ndpull'

I'm getting this in the terminal when running either beet ndpull or beet import:

Traceback (most recent call last):
  File "~/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/plugins.py", line 269, in load_plugins
    namespace = __import__(modname, None, None)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/.local/pipx/venvs/beets/lib/python3.11/site-packages/beetsplug/navidrome_sync/__init__.py", line 3, in <module>
    from . import sftpuploader
  File "~/.local/pipx/venvs/beets/lib/python3.11/site-packages/beetsplug/navidrome_sync/sftpuploader.py", line 1, in <module>
    import paramiko
ModuleNotFoundError: No module named 'paramiko'

error: unknown command 'ndpull'```

Pull Date Added from Navidrome

Hey, are there any plans to add this? I can't really use modified dates from files since they are a bit wrong unfortunately (and there seems to be now way to use creation date on Linux?).

sqlite3.OperationalError: no such column: mbz_track_id

This is a destructive operation, please make sure you have a backup of your Navidrome DB before continuing. Press enter to continue...
Traceback (most recent call last):
  File "~/.local/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "~/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/ui/__init__.py", line 1862, in main
    _raw_main(args)
  File "~/.local/pipx/venvs/beets/lib/python3.11/site-packages/beets/ui/__init__.py", line 1849, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "~/.spotdl/beets-navidrome_sync-main/beetsplug/navidrome_sync.py", line 126, in nd_sync
    self.nd_pull(lib, conn, cur)
  File "~/.spotdl/beets-navidrome_sync-main/beetsplug/navidrome_sync.py", line 343, in nd_pull
    for (item_id, artist, albumArtist, album, title, mb_trackid) in cur.execute('SELECT id, artist, album_artist, album, title, mbz_track_id FROM media_file;'):
                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: no such column: mbz_track_id

Option to disable the database warning

I'm trying to run the commands in the background, but I get an EOF error since I need to confirm the action. It would be great if there was an option to disable this.
I just removed this from the code directly for the time being.

The readme could use some clarification

"Copy the navidrome_sync directory to your beetsplug directory."

There is no such directory after you extract the zip file. We get beets-navidrome_sync-main instead. But that's probably not the directory you would want us to copy to the beetsplug directory?

The beets-navidrome_sync-main directory also has beetsplug directory. Are we supposed to rename this one into navidrome_sync and copy it into beetsplug directory or are we supposed to copy the contents of it into the beetsplug directory?

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.