Error using search or delete functions

google-music-scripts
#1

Hi @thebigmunch, first of all thanks for all your work in the previous tools and the work that you are doing in the new ones. You have created such an usefull api.

I use gmusicapi-scripts for a project i’m doing [GitHub - tomasvrubio/miTUBE: web application to generate music lists from youtube lists] and everything that I used worked. But I found a problem because I need user password having their oauth token to use the delete utility (because it connects like a mobile device).

When I saw this new tool I was surprised that no password was shown in the instructions to use “delete” but when I tried to use it got an error that can’t resolve. The manual says to use a “device_id” but I don’t know if I have to use more parameters or this error is because I don’t know yet a valid device_id. Reading the error seems that I need 1 more parameter but I don’t know what is missing.

I have the same error trying to delete or to search, both of them are using device_id and filters:


[tomas@fundacion tmp]$ gms search -u "xxxxx@gmail.com" --device-id "0x00112233aabbccdd" -f "title:pedro"
[2018-11-12 18:32:10] Logging in to Google Music
Traceback (most recent call last):
  File "/home/tomas/.local/bin/gms", line 11, in <module>
    sys.exit(gms())
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music_scripts/cli.py", line 391, in search
    exclude_filters=exclude_filter, all_excludes=all_excludes, yes=yes
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music_scripts/commands.py", line 95, in do_search
    exclude_filters=exclude_filters, all_excludes=all_excludes
TypeError: get_google_songs() missing 1 required positional argument: 'mm'

[tomas@fundacion tmp]$ gms delete -u xxxx@gmail.com -n -f "id:c16548b3-8315-3b27-85ab-8a7f5949838c" --device-id "+eGFGTbiyMktbPuvB5MfsA"
[2018-11-12 18:11:35] Logging in to Google Music
Traceback (most recent call last):
  File "/home/tomas/.local/bin/gms", line 11, in <module>
    sys.exit(gms())
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music_scripts/cli.py", line 264, in delete
    exclude_filters=exclude_filter, all_excludes=all_excludes, yes=yes
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music_scripts/commands.py", line 15, in do_delete
    exclude_filters=exclude_filters, all_excludes=all_excludes
TypeError: get_google_songs() missing 1 required positional argument: 'mm'

¿I’m doing something wrong?

Thanks for your help

#2

Thanks for the kind words.

You did nothing wrong. I forgot to update some things when I ported over the old gmusicapi-scripts code to my new framework. I actually refactored the whole project 2 weeks ago and fixed all that (I hope). But I forgot I hadn’t released it yet, because I was going to debut a new filter syntax and release a major version. I will release what I have without the new filter syntax some time today, so this will be fixed.

Yeah, my framework uses OAuth for the MobileClient as well as MusicManager, so no password needed and no issues with auth that have been reported recently in gmusicapi. As for device_id, it’s optional unless streaming (which my scripts don’t do) or if a valid MAC can’t be obtained on the machine. It will use your MAC address by default.

#3

Alright, new version released. Please check it out and see if I screwed anything else up : P

Also, be on the lookout for when I preview the new filter option syntax. It’s going to be more flexible and powerful.

#4

Thanks @thebigmunch, your update solved that error but now I’m stuck trying to filter songs to search/download/delete… Does it works like in gmusicapi-scripts or do I have to do it another way? You don’t specified it in the docs and I can’t filter songs.

An example:

[tomas@fundacion tmp]$ gms delete -u XXXX@gmail.com -n -f "id:c16548b3-8315-3b27-85ab-8a7f5949838c" --device-id "B9:27:EB:F5:91:2C"
Traceback (most recent call last):
  File "/home/tomas/.local/bin/gms", line 11, in <module>
    sys.exit(gms())
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 1064, in invoke
    sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 621, in make_context
    self.parse_args(ctx, args)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 880, in parse_args
    value, args = param.handle_parse_result(ctx, opts, args)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 1404, in handle_parse_result
    self.callback, ctx, self, value)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 78, in invoke_param_callback
    return callback(ctx, param, value)
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music_scripts/cli.py", line 67, in parse_filters
    raise ValueError(f"'{filter_}' is not a valid filter.")
ValueError: 'id:c16548b3-8315-3b27-85ab-8a7f5949838c' is not a valid filter.

Its there anywhere to see which filters can we use and how to use them?

Thanks for everything

#5

It looks like you have installed from git master? That includes a breaking change for the next major version bump with filtering. This is the new filtering syntax I mentioned in my previous post. Check the CHANGELOG on master now for how to use the new syntax as I didn’t get to writing proper docs for it yet.

#6

New filter syntax documentation now added to the /latest docs.

#7

Sorry, I tried to read everything but skipped the docs that you just said. Following the instructions works perfect:

[tomas@fundacion miTUBE]$ gms search -u "xxx@gmail.com" --device-id “0x00112233aabbccdd” -f ‘artist[pedro]’
[2018-11-23 18:35:58] Logging in to Google Music
[2018-11-23 18:35:58] Filtering songs
[2018-11-23 18:35:58] No songs found matching query
[2018-11-23 18:35:58] All done!

Thanks for your amazing work and all your help :slight_smile:

#8

OK, I have continued a bit and found what seems an error in DELETE function.

If I do a delete with the dry option all works OK:

[tomas@fundacion miTUBE]$ gms delete -n -y -u "xxx@gmail.com" --device-id "23:23:23:23:23:23" -f 'id[2edb523c-84b4-34cb-b8fd-e3f56f854703]'
[2018-11-23 18:47:52] Logging in to Google Music
[2018-11-23 18:47:53] Filtering songs
[2018-11-23 18:47:53] Found 1 songs to delete
[2018-11-23 18:47:53] Bad Habit -- The Kooks -- Pruebando (2edb523c-84b4-34cb-b8fd-e3f56f854703)
[2018-11-23 18:47:53] All done!

But If I try to actually delete it fails:

[tomas@fundacion miTUBE]$ gms delete -y -u "xxx@gmail.com" --device-id "23:23:23:23:23:23" -f 'id[2edb523c-84b4-34cb-b8fd-e3f56f854703]'
[2018-11-23 18:48:01] Logging in to Google Music
[2018-11-23 18:48:02] Filtering songs
Traceback (most recent call last):
  File "/home/tomas/.local/bin/gms", line 11, in <module>
    sys.exit(gms())
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music_scripts/commands/delete.py", line 68, in delete
    logger.debug(f"Deleting {title} -- {artist} -- {album} ({song_id})")
UnboundLocalError: local variable 'title' referenced before assignment

It’s all because of the “delete without asking confirmation” option (y) because If I quit it all works:

[tomas@fundacion miTUBE]$ gms delete -u "xxx@gmail.com" --device-id "23:23:23:23:23:23" -f 'id[2edb523c-84b4-34cb-b8fd-e3f56f854703]'
[2018-11-23 18:48:28] Logging in to Google Music
[2018-11-23 18:48:29] Filtering songs

Are you sure you want to delete 1 song(s) from Google Music? (y/n) n
[2018-11-23 18:48:32] No songs deleted
[2018-11-23 18:48:32] All done!
#9

It’s failing (with confirmation, when you give it, or without asking confirmation) at the moment that it’s going to delete the file from the server:

[tomas@fundacion miTUBE]$ gms delete -u "xxx@gmail.com" --device-id "23:23:23:23:23:23" -f 'id[2edb523c-84b4-34cb-b8fd-e3f56f854703]'
[2018-11-23 19:01:02] Logging in to Google Music
[2018-11-23 19:01:03] Filtering songs

Are you sure you want to delete 1 song(s) from Google Music? (y/n) y
Traceback (most recent call last):
  File "/home/tomas/.local/bin/gms", line 11, in <module>
    sys.exit(gms())
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music_scripts/commands/delete.py", line 68, in delete
    logger.debug(f"Deleting {title} -- {artist} -- {album} ({song_id})")
UnboundLocalError: local variable 'title' referenced before assignment
#10

Looks like I misplaced a logging call along the way. Should be fixed in master now.

#11

I wasn’t clear. I’m using the version (1.1.1) that gets installed with pip so your changes haven’t solved my problem. I have tried to get your changes in master in my files but didn’t work.

I will wait to get the changes in your next pip release (not in a hurry cause I have a lot of other things to get finish not related with googleMusic).

Thanks!!

#12

pip install -U git+https://github.com/thebigmunch/google-music-scripts to install from git. Might be Monday before I get the cascade of releases necessary to release the next version of this. It will still update properly from PyPI come next release.

#13

All new versions released.

#14

Did you forgot to release google-music-scripts? Or am I misreading you?

With the option you said with git+… I get no good results:

[tomas@fundacion ~]$ gms search -y -u "xxx@gmail.com" --device-id "23:23:23:23:23:23" -f 'id[2edb523c-84b4-34cb-b8fd-e3f56f854703]'
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 578, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 895, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (audio-metadata 0.2.0 (/home/tomas/.local/lib/python3.7/site-packages), Requirement.parse('audio-metadata<0.2,>=0.1'), {'google-music-utils'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tomas/.local/bin/gms", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3112, in <module>
    @_call_aside
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3096, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3125, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 580, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 593, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 786, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (audio-metadata 0.2.0 (/home/tomas/.local/lib/python3.7/site-packages), Requirement.parse('audio-metadata<0.2,>=0.1'), {'google-music-utils'})
#15

I sure did : P Was a super busy morning : )

Released properly now.

#16

Also, I fixed the required dependency version in google-music-utils, so the version conflict should be fixed with an upgrade install.

#17

It’s finally working. Now I can implement delete options in my application :slight_smile:

The next step its using the playlist functions you’re doing. Now I’m using album metadata as an identificator to make playlists in Google Music. Looking forward to use it when you finish your work.

Thanks!!

#18

Hi @thebigmunch

Search and Delete are working perfect but now it seems that upload is broken. I can’t get it working and it seems that it’s cause missing “auth_status” field.

gms upload -u xxx@gmail.com --uploader-id "B9:27:EB:F5:91:2C" -l ./UJWk_KNbDHo.mp3
[2018-11-30 05:14:04] Logging in to Google Music
Traceback (most recent call last):
  File "/home/tomas/.local/bin/gms", line 11, in <module>
    sys.exit(gms())
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/tomas/.local/lib/python3.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music_scripts/commands/upload.py", line 117, in upload
    mm = google_music.musicmanager(username, uploader_id=uploader_id)
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music/api.py", line 51, in musicmanager
    token=token
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music/clients/musicmanager.py", line 64, in __init__
    self._upauth(uploader_id, uploader_name)
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music/clients/musicmanager.py", line 70, in _upauth
    self._call(mm_calls.UpAuth, uploader_id, uploader_name)
  File "/home/tomas/.local/lib/python3.7/site-packages/tenacity/__init__.py", line 292, in wrapped_f
    return self.call(f, *args, **kw)
  File "/home/tomas/.local/lib/python3.7/site-packages/tenacity/__init__.py", line 358, in call
    do = self.iter(retry_state=retry_state)
  File "/home/tomas/.local/lib/python3.7/site-packages/tenacity/__init__.py", line 331, in iter
    raise retry_exc.reraise()
  File "/home/tomas/.local/lib/python3.7/site-packages/tenacity/__init__.py", line 167, in reraise
    raise self.last_attempt.result()
  File "/usr/lib64/python3.7/concurrent/futures/_base.py", line 425, in result
    return self.__get_result()
  File "/usr/lib64/python3.7/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/home/tomas/.local/lib/python3.7/site-packages/tenacity/__init__.py", line 361, in call
    result = fn(*args, **kwargs)
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music/clients/base.py", line 77, in _call
    return call.parse_response(response.headers, response.content)
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music_proto/musicmanager/models.py", line 41, in parse_response
    if not self.check_success(res_body):
  File "/home/tomas/.local/lib/python3.7/site-packages/google_music_proto/musicmanager/calls.py", line 495, in check_success
    return response.HasField('auth_status') and response.auth_status == upload_pb2.UploadResponse.OK
ValueError: Unknown field auth_status.

If you prefer that I open issues for this problems I’m finding say to me.

#19

Generally, bugs should be reported to the tracker. And, unrelated posts on here should be separated into a new topic. Also, probably a good idea to look on the Issue Tracker for things; this is already a solved issue there.