From 1f2b8cef971292c2caf2249e4494e8aa4f8e9e5a Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Wed, 14 Jun 2017 19:05:38 -0400 Subject: [PATCH] Tiny code and docs fixes for gmusic (#2586) --- beetsplug/gmusic.py | 9 ++++++--- docs/plugins/gmusic.rst | 45 +++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/beetsplug/gmusic.py b/beetsplug/gmusic.py index 545d5cae42..f935fce08c 100644 --- a/beetsplug/gmusic.py +++ b/beetsplug/gmusic.py @@ -13,7 +13,7 @@ # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. -"""Uploads files to Google Play Music""" +"""Upload files to Google Play Music and list songs in its library.""" from __future__ import print_function import os.path @@ -41,6 +41,7 @@ def __init__(self): def commands(self): gupload = Subcommand('gmusic-upload', help=u'upload your tracks to Google Play Music') + gupload.func = self.upload search = Subcommand('gmusic-songs', help=u'list of songs in Google Play Music library' @@ -51,7 +52,6 @@ def commands(self): search.parser.add_option('-a', '--artist', dest='artist', action='store_true', help='Search by artist') - gupload.func = self.upload search.func = self.search return [gupload, search] @@ -75,7 +75,10 @@ def search(self, lib, opts, args): Mobileclient.FROM_MAC_ADDRESS) files = mobile.get_all_songs() except NotLoggedIn: - ui.print_('Error occured. Please check your email and password') + ui.print_( + 'Authentication error. Please check your email and password.' + ) + return if not args: for i, file in enumerate(files, start=1): print(i, ui.colorize('blue', file['artist']), diff --git a/docs/plugins/gmusic.rst b/docs/plugins/gmusic.rst index e9d81b6598..4941033a38 100644 --- a/docs/plugins/gmusic.rst +++ b/docs/plugins/gmusic.rst @@ -1,48 +1,49 @@ Gmusic Plugin ============= -This plugin allows you to manage your Google Play Music library with beets. +The ``gmusic`` plugin lets you upload songs to Google Play Music and query +songs in your library. Installation ------------ -The plugin requires `gmusic`_. You can install it using `pip`:: +The plugin requires `gmusicapi`_. You can install it using `pip`:: pip install gmusicapi -.. _gmusic: https://github.com/simon-weber/gmusicapi/ +.. _gmusicapi: https://github.com/simon-weber/gmusicapi/ -Usage ------ +Then, you can enable the ``gmusic`` plugin in your configuration (see +:ref:`using-plugins`). -To use the ``gmusic`` plugin, enable it in your configuration file. -Then, add your Google email and password to configuration file under a ``gmusic`` section, if you want to be able to search for songs in your library. -It's not necessary if you only upload files. :: - - gmusic: - email: email - password: password +Usage +----- +To upload tracks to Google Play Music, use the ``gmusic-upload`` command:: -If you want to upload your tracks use ``gmusic-upload`` command:: + beet gmusic-upload [QUERY] - beet gmusic-upload [ARGS...] +If you don't include a query, the plugin will upload your entire collection. -If no arguments are provided, it will upload your entire beet collection. +To query the songs in your collection, you will need to add your Google +credentials to your beets configuration file. Put your Google username and +password under a section called ``gmusic``, like so:: -In case you want to search for songs in your Google Music library just use:: + gmusic: + email: user@example.com + password: seekrit - beet gmusic-songs [OPTS...] [ARGS...] +Then, use the ``gmusic-songs`` command to list music:: - Options: - -a, --artist search by artist name - -t, --track search by track + beet gmusic-songs [-at] [ARGS] -For example:: +Use the ``-a`` option to search by artist and ``-t`` to search by track. For +example:: beet gmusic-songs -a John Frusciante beet gmusic-songs -t Black Hole Sun -If you want a list of all songs simply leave it without arguments and options. \ No newline at end of file +For a list of all songs in your library, run ``beet gmusic-songs`` without any +arguments.