Merge pull request #2998 from shuaiscott/master

Adding gmusic ability to upload on import
This commit is contained in:
Adrian Sampson 2018-08-09 22:47:41 -04:00 committed by GitHub
commit 2d2428fa05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View file

@ -38,6 +38,12 @@ class Gmusic(BeetsPlugin):
else:
self.m.perform_oauth()
self.config.add({
u'auto': False,
})
if self.config['auto']:
self.import_stages = [self.autoupload]
def commands(self):
gupload = Subcommand('gmusic-upload',
help=u'upload your tracks to Google Play Music')
@ -57,11 +63,22 @@ class Gmusic(BeetsPlugin):
def upload(self, lib, opts, args):
items = lib.items(ui.decargs(args))
files = [x.path.decode('utf-8') for x in items]
files = self.getpaths(items)
ui.print_(u'Uploading your files...')
self.m.upload(filepaths=files)
ui.print_(u'Your files were successfully added to library')
def autoupload(self, session, task):
items = task.imported_items()
files = self.getpaths(items)
self._log.info(u'Uploading files to Google Play Music...', files)
self.m.upload(filepaths=files)
self._log.info(u'Your files were successfully added to your '
+ 'Google Play Music library')
def getpaths(self, items):
return [x.path for x in items]
def search(self, lib, opts, args):
password = config['gmusic']['password']
email = config['gmusic']['email']

View file

@ -16,6 +16,8 @@ New features:
:bug:`2944`
* Added whitespace padding to missing tracks dialog to improve readability.
:user:`jams2`
* Automatically upload to Google Play Music library on track import.
:user:`shuaiscott`
Fixes:

View file

@ -21,6 +21,14 @@ Then, you can enable the ``gmusic`` plugin in your configuration (see
Usage
-----
To automatically upload all tracks to Google Play Music, add the ``auto: yes``
parameter to your configuration file like the example below::
gmusic:
auto: yes
email: user@example.com
password: seekrit
To upload tracks to Google Play Music, use the ``gmusic-upload`` command::
beet gmusic-upload [QUERY]