sigma67 / ytmusicapi

Unofficial API for YouTube Music
https://ytmusicapi.readthedocs.io
MIT License
1.71k stars 194 forks source link

Fail to upload songs #1

Closed ccyang2019 closed 4 years ago

ccyang2019 commented 4 years ago

I tried to use this API to upload songs to youtube music. But always fail to do that.

#!/usr/bin/env python3
# -*- coding:UTF-8 -*-
import os
from ytmusicapi import YTMusic
ytmusic = YTMusic('yt_header.json')
file = "test.mp3"
status=ytmusic.upload_song(file)
print(status)

I got return status "__STATUS_SUCCEEDED__", but I fail to see my uploaded song in youtube music.

200
{'X-GUploader-UploadID': 'AEnB2UpJYZnMeaGnKkJuNPM1Q75X5WaFXkxO8BGfxtUcxjN7tAqhIJysFn3CF5c0zsd2iGteKHcsN87KGhA-qEG-6NMpcnB0i1qEHxyyvOeYh4MSChuPVd4', 'X-Goog-Upload-Status': 'final', 'Content-Length': '0', 'Date': 'Fri, 03 Apr 2020 07:48:50 GMT', 'Server': 'UploadServer', 'Content-Type': 'text/html; charset=UTF-8'}

I tried to do some fail experiments and the return status is always "__STATUS_SUCCEEDED__"

sigma67 commented 4 years ago

Hey, please make sure you're using the latest version 0.5.1. There was a bug with uploads in 0.5. In particular, there is now an authentication check when providing auth headers, which should have triggered on the first of your fail tests.

I tested the code you posted and it worked fine for me, so there is no issue with it. There is also a processing delay, so your song should first show up as "processing" in the songs section of your library.

As for mp4 files and same songs, the library currently does not check this. Duplicates can be uploaded without issues. So make sure your file is correct.

ccyang2019 commented 4 years ago

yes. thanks for your comment. It should be working now. Change another account with less uploaded songs to debug this issue. I can see my uploaded mp3 songs now. It takes several minutes to process my uploaded songs.
image But I still have following issues under debugging:

  1. only mp3 song works. my ".m4a", and ".flac" songs uploaded and show processing, then after several minutes no showed in the uploaded list. As attached, the 2 song processing in above picture, which are not showed in the uploaded list after several minutes.
    image
  1. duplicated songs not detected like web upload flow.
  2. mp3 tag like "album", "title" are lost after uploaded. it's ok by web upload .
    image
sigma67 commented 4 years ago

Hey, thanks for bringing up these issues. They are valid.

  1. I have not tested this with other file formats. Let me know if you're able to figure out the issue. Do m4a and flac work on the web UI?
  2. The web upload flow only detects duplicates after the upload. Not sure why they're not detected when uploading with the library. It might have something to do with the additional 'OPTIONS' calls that the web UI does, which I left out since it worked without them. I'll look into this.
  3. I'm not sure why mp3 tags and album picture are lost when uploading with the library function. Might also be related to the OPTIONS calls.

Let me know if you've done any additional experiments or reverse engineered something successfully.

sigma67 commented 4 years ago

Hey, just letting you know that I've found the problem. Files should now be uploaded correctly. All three issues should be fixed in the latest version v0.5.2

ccyang2019 commented 4 years ago

Hi sigma67,

yes. my issue is solved in v.0.5.2. I can upload my *.flac files successfully now.

thank you !