Giter Site home page Giter Site logo

jaymoulin / youtube-music-uploader Goto Github PK

View Code? Open in Web Editor NEW
17.0 3.0 1.0 91 KB

Python Daemon to upload music to Youtube Music

Home Page: https://brands.jaymoulin.me/me/youtube-music-uploader

License: MIT License

Makefile 11.51% Python 75.26% Dockerfile 5.51% Shell 7.73%
youtube youtube-music upload youtube-upload python python3 docker docker-image music music-library

youtube-music-uploader's Introduction

logo

Youtube Music Uploader

latest release PyPI version PayPal donation Buy me a coffee Buy me a cofee

DISCLAIMER: As-of 2021, this product does not have a free support team anymore. If you want this product to be maintained, please support on Patreon.

(This product is available under a free and permissive license, but needs financial support to sustain its continued improvements. In addition to maintenance and stability there are many desirable features yet to be added.)

This program will create a Daemonic folder to upload your music library to Youtube Music

This work is based upon Sigma67's Youtube Music API.

Installation

This program needs watchdog, ytmusicapi and requests Python libraries to work.

apt-get install python3-pip build-essential
pip3 install youtube-music-uploader

Once installed, You have to authenticate to Youtube Music via the youtube-music-auth command

# Usage youtube-music-auth [path_to_oauth_cred_file=~/oauth]

If first parameter is not defined, the script will try to store/load your oauth credentials through the ~/oauth file.

Then follow the setup instructions provided https://ytmusicapi.readthedocs.io/en/latest/setup.html#copy-authentication-headers.

Usage

Uploader

This program will scan a given directory for new elements to upload them to Youtube Music. First, launch the daemon to watch a directory new inputs.

usage: youtube-music-upload [-h] [-v] [--directory DIRECTORY] [--oauth OAUTH] [-r]
                          [-o] [--deduplicate_api DEDUPLICATE_API]

optional arguments:
  -h, --help            show this help message and exit
  -v, --version         show version number and exit
  --directory DIRECTORY, -d DIRECTORY
                        Music Folder to upload from (default: .)
  --oauth OAUTH, -a OAUTH
                        Path to oauth file (default: ~/oauth)
  -r, --remove          Remove the file on your hard drive if it was already successfully uploaded (default: False)
  -o, --oneshot         Upload folder and exit (default: False)
  -l, --listener_only   Only listen for new files, does not parse all files at launch (default: False)
  -e ERROR_FILE_PATH, --log ERROR_FILE_PATH
                        Log to a specified file path (Default stderr)
  -w DEDUPLICATE_API, --deduplicate_api DEDUPLICATE_API
                        Deduplicate API (should be HTTP and compatible with
                        the manifest (see README)) (default: None)

Deduplicate

This program will send all files or the specified file to the deduplication API

usage: youtube-music-upload-deduplicate [-h] --deduplicate_api DEDUPLICATE_API
                                   [--directory DIRECTORY] [--file FILE]
                                   [--remove]

optional arguments:
  -h, --help            show this help message and exit
  --directory DIRECTORY, -d DIRECTORY
                        Music Folder to deduplicate
  --file FILE, -f FILE
                        Music file path to deduplicate
  -r, --remove          Unmark specified file/folder (default: False)
  -w DEDUPLICATE_API, --deduplicate_api DEDUPLICATE_API
                        Deduplicate API (should be HTTP and compatible with
                        the manifest (see README)) (default: None)

Deduplication API

Preface

This API is completely optional. You don't have to implement this. It will only help you to avoid useless Google calls

Thanks to Brian Doherty, a local snapshot is now made to avoid external deduplication calls on local updated files.

You can use your own API implementation to avoid multiple Youtube Music uploads. This API should match with the following requirements.

You may want to use this existing one : Google MusicManager Deduplicate API.

Exists

path method parameter status code
/ GET name description value description
path path of your file 200 or 204 Your file was already uploaded
404 (or whatever) Your file was NOT uploaded

Saving

path method parameter status code
/ POST name description value description
path path of your file whatever Status code does not change anything

Removing

path method parameter status code
/ DELETE name description value description
path path of your file whatever Status code does not change anything

About

Requirements

Youtube Music Uploader works with Python 3 or above.

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub

Author

Jay MOULIN See also the list of contributors which participated in this program.

License

Youtube Music Uploader is licensed under the MIT License

youtube-music-uploader's People

Contributors

brian-doherty avatar jaymoulin avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

Forkers

brian-doherty

youtube-music-uploader's Issues

youtube-music-auth is broken because ytmusicapi has changed

Version Number: 1.3.0

If you're using docker, Output of docker inspect jaymoulin/youtube-music-uploader --format='{{index .Config.Labels.version}}':

(paste your output here)

Description

When running youtube-music-auth the following error message appears:

Traceback (most recent call last):
File "/home/brian/.local/bin/youtube-music-auth", line 8, in
sys.exit(main())
File "/home/brian/.local/lib/python3.10/site-packages/youtube_music_uploader/auth.py", line 17, in main
auth(sys.argv[1] if len(sys.argv) > 1 else os.environ['HOME'] + '/oauth')
File "/home/brian/.local/lib/python3.10/site-packages/youtube_music_uploader/auth.py", line 12, in auth
if YTMusic.setup(auth_file):
AttributeError: type object 'YTMusic' has no attribute 'setup'

Steps to reproduce the issue:
1.
2.
3.

Describe the results you received:

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

Meaning of "Response 409"

Version Number: 1.3.0

Hi.
I'd like to ask what "Response 409" means. Like in:

[...]22:10:36,160 - youtube_[...]_daemon - INFO - Should upload ./A/AAA/BBB/04 Boogie.mp3? 
[...]22:10:36,160 - youtube[...]aemon - INFO - Uploading ./A/AAA/BBB/04 Boogie.mp3
[...]22:10:40,999 - youtub[...]aemon - INFO - Not uploaded ./A/AAA/BBB/04 Boogie.mp3: <Response [409]>
[...]22:10:41,000 - youtube[...]daemon - INFO - Should upload ./A/AAA/BBB/08 Bomb.mp3? 
[...]22:10:41,000 - youtu[...]aemon - INFO - Uploading ./A/AAA/BBB/08 Bomb.mp3
[...]22:10:45,369 - youtu[...]daemon - INFO - Not uploaded ./A/AAA/BBB/08 Bomb.mp3: <Response [409]>

Is that mean file already exists on YTM side? I checked like 20 of such responses, and they all were there, so I'm fairly certain at this point, but I'd like to confirm that with you...

Thank you

Music not uploading

Version Number: 1.0.0

1.0.0

Description
The files are not getting uploaded to Youtube.

Steps to reproduce the issue:

  1. Create docker container including the dedup API (https://github.com/jaymoulin/google-musicmanager-dedup-api)
  2. Follow instructions for receiving cookie information.
  3. Watch the log grow

Describe the results you received:
Log of one song, however this is the same for all songs.

youtubemusicuploader | 2020-10-22 20:07:22,130 - youtube_music_uploader.uploader_daemon - INFO - Should upload /media/library/Country/John Denver - The Essential John Denver 2007(2cd's)/CD1/14 - Thank God I'm A Country Boy.mp3?
youtubemusicdedup | 172.18.0.3 - - [22/Oct/2020 20:07:22] "GET / HTTP/1.1" 404 -
youtubemusicuploader | 2020-10-22 20:07:22,139 - youtube_music_uploader.uploader_daemon - INFO - Deduplicate API: file exists? no
youtubemusicuploader | 2020-10-22 20:07:22,140 - youtube_music_uploader.uploader_daemon - INFO - Uploading /media/library/Country/John Denver - The Essential John Denver 2007(2cd's)/CD1/14 - Thank God I'm A Country Boy.mp3
youtubemusicuploader | 2020-10-22 20:07:22,867 - youtube_music_uploader.uploader_daemon - INFO - Not uploaded /media/library/Country/John Denver - The Essential John Denver 2007(2cd's)/CD1/14 - Thank God I'm A Country Boy.mp3

Describe the results you expected:
I expected the music to get uploaded.

Additional information you deem important (e.g. issue happens only occasionally):

  • I have verified that the oauth key has been created
  • I tried on both a linux and windows docker environment
  • And thank you for creating this API. With Google Play Music EOL and the music manager not working anymore, this would really be useful!

Exception on song upload

Description
While trying to upload with the following command:
youtube-music-upload -d "D:\Music"

I'm getting this Exception in logs:
youtube_music_uploader.uploader_daemon - INFO - Uploading D:\Musique\song.mp3
youtube_music_uploader.uploader_daemon - INFO - Exception: Not uploaded D:\Musique\song.mp3: 'x-goog-upload-url'
and this error message in console:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python310\lib\threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "C:\Python310\lib\site-packages\watchdog\observers\api.py", line 199, in run
    self.dispatch_events(self.event_queue, self.timeout)
  File "C:\Python310\lib\site-packages\watchdog\observers\api.py", line 372, in dispatch_events
    handler.dispatch(event)
  File "C:\Python310\lib\site-packages\watchdog\events.py", line 272, in dispatch
    {
  File "C:\Python310\lib\site-packages\youtube_music_uploader\uploader_daemon.py", line 44, in on_created
    upload_file(
  File "C:\Python310\lib\site-packages\youtube_music_uploader\uploader_daemon.py", line 121, in upload_file
    raise e
  File "C:\Python310\lib\site-packages\youtube_music_uploader\uploader_daemon.py", line 89, in upload_file
    status = api.upload_song(file_path)
  File "C:\Python310\lib\site-packages\ytmusicapi\mixins\uploads.py", line 217, in upload_song
    upload_url = response.headers['X-Goog-Upload-URL']
  File "C:\Python310\lib\site-packages\requests\structures.py", line 54, in __getitem__
    return self._store[key.lower()][1]
KeyError: 'x-goog-upload-url'

Logging went without a hitch, so I believe I did things right on this point.
Waiting on your aswer! Thank you for the work.

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.