simon-weber / gmusicapi

An unofficial client library for Google Music.
https://unofficial-google-music-api.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.49k stars 258 forks source link

Uploading flacs: can't use mutagen FLAC bitrate #69

Closed simon-weber closed 11 years ago

simon-weber commented 11 years ago

@whamm reported this in https://github.com/simon-weber/Unofficial-Google-Music-API/issues/51#issuecomment-12591981. Mutagen doesn't provide a bitrate for FLACs; we'll have to come up with one ourselves (after determining what the music manager does for FLACs)

ghost commented 11 years ago

Well since it converts them to 320kbps mp3s does it need to be computed?

simon-weber commented 11 years ago

You're right, of course: a FLAC bitrate is pretty useless, and moreso here because of the unavoidable transcoding.

I just need to see what the Music Manager provides. In all likelihood, it does something really simple (eg always give 320, or just leave it out).

I hope to get to this tomorrow.

simon-weber commented 11 years ago

For whatever reason, the Music Manager does send an accurate bitrate for FLACs. bits / milliseconds is close enough for me; I can't see what difference it would make.

simon-weber commented 11 years ago

33785145ae518bdb84e4ad808ed651e66c472ae2 fixes this for me. I'm going to close this; feel free to reopen if this doesn't fix the issue for you.

ghost commented 11 years ago

@simon-weber I'm not sure it's doing anything now? It says that it's uploading, but it finishes too quickly and it doesn't show up on the web. Not sure how to debug this one. Any hints?

ghost commented 11 years ago

So it seems the scan and match breaks it, (just pulled the latest protocol-fixes)

2013-01-28 08:55:05,764 - gmusicapi.Api - ERROR - couldn't create scan and match sample for 'music/Infected Mushroom.flac'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-2013.01.05-py2.7.egg/gmusicapi/api.py", line 841, in _upload_new
    contents, sample_request, track, self.uploader_id)
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-2013.01.05-py2.7.egg/gmusicapi/api.py", line 653, in _make_call
    request = protocol.build_request(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-2013.01.05-py2.7.egg/gmusicapi/newprotocol/shared.py", line 64, in build_request
    val = val(*args, **kwargs)
  File "<string>", line 2, in dynamic_data
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-2013.01.05-py2.7.egg/gmusicapi/newprotocol/musicmanager.py", line 24, in pb
    msg = f(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/gmusicapi-2013.01.05-py2.7.egg/gmusicapi/newprotocol/musicmanager.py", line 422, in dynamic_data
    raise ValueError(err_msg)
ValueError: could not create a scan and match sample with avconv. output: 'None'
to_upload: {}
Finished uploading.

When resetting to 33785145ae518bdb84e4ad808ed651e66c472ae2, it completes too fast and never uploads anything. No errors though.

simon-weber commented 11 years ago

@whamm: It looks like avconv isn't installed: that's the new dependency for scan + match (which replaces the ffmpeg dependency).

f3125f15bd11025d46c5724fd4892921590e0c8a should give you a better error message if it's not installed.

Note that you want to be doing, eg:

uploaded, matched, not_uploaded = api.upload('foo.mp3')
print uploaded, matched, not_uploaded

to see the results of the new upload code.

ghost commented 11 years ago

@simon-weber thanks! It does indeed upload now, however I'm still facing the issue of the transcoded flac is not playable on the web interface as you mentioned somewhere else, and the download is a 404.

Progress! :dancers:

simon-weber commented 11 years ago

Good to hear!

The hard work is pretty much done. I just need to figure out for sure when clientside transcoding takes place, and then uploading will be back online.

stephenjamieson commented 11 years ago

Can I just re-encode them myself before uploading them with the api until this issue gets looked at? Do you have any suggestions for easy transcoding on linux to mp3 320 that keeps the metadata?

simon-weber commented 11 years ago

There are a lot of options; pretty much any of them will work. I like avconv. Here's a link that goes through a few options.