From 69b4c68b6383bc32d47d05aff35b2586f763744d Mon Sep 17 00:00:00 2001 From: Scott Carlson Date: Sat, 4 Aug 2018 21:58:29 -0500 Subject: [PATCH 1/8] Adding autoupload method to upload on import --- beetsplug/gmusic.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/beetsplug/gmusic.py b/beetsplug/gmusic.py index 259d2725a..ecbc5569a 100644 --- a/beetsplug/gmusic.py +++ b/beetsplug/gmusic.py @@ -37,6 +37,9 @@ class Gmusic(BeetsPlugin): self.m.login() else: self.m.perform_oauth() + + if self.config['auto'].get(bool): + self.import_stages = [self.autoupload] def commands(self): gupload = Subcommand('gmusic-upload', @@ -61,6 +64,13 @@ class Gmusic(BeetsPlugin): 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 = [x.path.decode('utf-8') for x in items] + ui.print_(u'Uploading your files...') + self.m.upload(filepaths=files) + ui.print_(u'Your files were successfully added to library') def search(self, lib, opts, args): password = config['gmusic']['password'] From 697a55e6e317843e2d12a9193c83fb7c85798864 Mon Sep 17 00:00:00 2001 From: Scott Carlson Date: Sat, 4 Aug 2018 22:04:14 -0500 Subject: [PATCH 2/8] Adding auto parameter info Adding auto parameter info to explain usage and functionality of importing all tracks to Google Play Music --- docs/plugins/gmusic.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/plugins/gmusic.rst b/docs/plugins/gmusic.rst index d0ba96671..b2622c25d 100644 --- a/docs/plugins/gmusic.rst +++ b/docs/plugins/gmusic.rst @@ -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`` +parameter to your configuration file like the example below: + + gmusic: + auto + email: user@example.com + password: seekrit + To upload tracks to Google Play Music, use the ``gmusic-upload`` command:: beet gmusic-upload [QUERY] From 136a77671da0c6381661000f14fb47d9785577fc Mon Sep 17 00:00:00 2001 From: Scott Carlson Date: Sat, 4 Aug 2018 22:42:45 -0500 Subject: [PATCH 3/8] Fixing gmusic docs --- docs/plugins/gmusic.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/plugins/gmusic.rst b/docs/plugins/gmusic.rst index b2622c25d..a08c0abfa 100644 --- a/docs/plugins/gmusic.rst +++ b/docs/plugins/gmusic.rst @@ -21,11 +21,11 @@ Then, you can enable the ``gmusic`` plugin in your configuration (see Usage ----- -To automatically upload all tracks to Google Play Music, add the ``auto`` -parameter to your configuration file like the example below: +To automatically upload all tracks to Google Play Music, add the ``auto: yes`` +parameter to your configuration file like the example below:: gmusic: - auto + auto: yes email: user@example.com password: seekrit From 4fc15d2b175a9ac3fe21219fc4edf15bb0833f1f Mon Sep 17 00:00:00 2001 From: Scott Carlson Date: Sat, 4 Aug 2018 23:49:59 -0500 Subject: [PATCH 4/8] Adding auto to default configs --- beetsplug/gmusic.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/beetsplug/gmusic.py b/beetsplug/gmusic.py index ecbc5569a..69f800c00 100644 --- a/beetsplug/gmusic.py +++ b/beetsplug/gmusic.py @@ -37,7 +37,10 @@ class Gmusic(BeetsPlugin): self.m.login() else: self.m.perform_oauth() - + + self.config.add({ + u'auto': False, + }) if self.config['auto'].get(bool): self.import_stages = [self.autoupload] From 61363c8cd9809ca866b42bf703a322a43395d331 Mon Sep 17 00:00:00 2001 From: Scott Carlson Date: Sat, 4 Aug 2018 23:54:58 -0500 Subject: [PATCH 5/8] Fixing user messages to be more explicit --- beetsplug/gmusic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/beetsplug/gmusic.py b/beetsplug/gmusic.py index 69f800c00..26309d1a9 100644 --- a/beetsplug/gmusic.py +++ b/beetsplug/gmusic.py @@ -71,9 +71,9 @@ class Gmusic(BeetsPlugin): def autoupload(self, session, task): items = task.imported_items() files = [x.path.decode('utf-8') for x in items] - ui.print_(u'Uploading your files...') + ui.print_(u'Uploading your files to Google Play Music...') self.m.upload(filepaths=files) - ui.print_(u'Your files were successfully added to library') + ui.print_(u'Your files were successfully added to your Google Play Music library') def search(self, lib, opts, args): password = config['gmusic']['password'] From ef4490087b4fa68ba1e4ccbf066d985d9736271b Mon Sep 17 00:00:00 2001 From: Scott Carlson Date: Sun, 5 Aug 2018 00:17:19 -0500 Subject: [PATCH 6/8] Fixing Flake8 line issues --- beetsplug/gmusic.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/beetsplug/gmusic.py b/beetsplug/gmusic.py index 26309d1a9..6613887c2 100644 --- a/beetsplug/gmusic.py +++ b/beetsplug/gmusic.py @@ -37,7 +37,7 @@ class Gmusic(BeetsPlugin): self.m.login() else: self.m.perform_oauth() - + self.config.add({ u'auto': False, }) @@ -67,13 +67,14 @@ class Gmusic(BeetsPlugin): 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 = [x.path.decode('utf-8') for x in items] ui.print_(u'Uploading your files to Google Play Music...') self.m.upload(filepaths=files) - ui.print_(u'Your files were successfully added to your Google Play Music library') + ui.print_(u'Your files were successfully added to your ' + + 'Google Play Music library') def search(self, lib, opts, args): password = config['gmusic']['password'] From cfe8ed9c34c78a41279bdd04a0e72e71b110cf28 Mon Sep 17 00:00:00 2001 From: Scott Carlson Date: Mon, 6 Aug 2018 16:41:09 -0500 Subject: [PATCH 7/8] Gmusic fixes based on review and changelog addition * Fixes based on review and changelog addition --- beetsplug/gmusic.py | 13 ++++++++----- docs/changelog.rst | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/beetsplug/gmusic.py b/beetsplug/gmusic.py index 6613887c2..efe855663 100644 --- a/beetsplug/gmusic.py +++ b/beetsplug/gmusic.py @@ -41,7 +41,7 @@ class Gmusic(BeetsPlugin): self.config.add({ u'auto': False, }) - if self.config['auto'].get(bool): + if self.config['auto']: self.import_stages = [self.autoupload] def commands(self): @@ -63,19 +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 = [x.path.decode('utf-8') for x in items] - ui.print_(u'Uploading your files to Google Play Music...') + files = self.getpaths(items) + self._log.info(u'Uploading files to Google Play Music...', files) self.m.upload(filepaths=files) - ui.print_(u'Your files were successfully added to your ' + 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'] diff --git a/docs/changelog.rst b/docs/changelog.rst index d487f31f5..4a8b9daf3 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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: From a605a1ba5564b7f455f26de7e4928c1f0c634a90 Mon Sep 17 00:00:00 2001 From: Scott Carlson Date: Thu, 9 Aug 2018 21:28:35 -0500 Subject: [PATCH 8/8] Fixing Flake8 spacing complaint --- beetsplug/gmusic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/beetsplug/gmusic.py b/beetsplug/gmusic.py index efe855663..98f368cb4 100644 --- a/beetsplug/gmusic.py +++ b/beetsplug/gmusic.py @@ -74,7 +74,7 @@ class Gmusic(BeetsPlugin): 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') + + 'Google Play Music library') def getpaths(self, items): return [x.path for x in items]