mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 21:33:13 -07:00
Update vendored beets to 1.6.0
Updates colorama to 0.4.6 Adds confuse version 1.7.0 Updates jellyfish to 0.9.0 Adds mediafile 0.10.1 Updates munkres to 1.1.4 Updates musicbrainzngs to 0.7.1 Updates mutagen to 1.46.0 Updates pyyaml to 6.0 Updates unidecode to 1.3.6
This commit is contained in:
parent
5073ec0c6f
commit
56c6773c6b
385 changed files with 25143 additions and 18080 deletions
|
@ -1,6 +1,4 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# This file is part of beets.
|
||||
# Copyright 2017, Tigran Kostandyan.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
|
@ -13,84 +11,15 @@
|
|||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
"""Upload files to Google Play Music and list songs in its library."""
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
import os.path
|
||||
"""Deprecation warning for the removed gmusic plugin."""
|
||||
|
||||
from beets.plugins import BeetsPlugin
|
||||
from beets import ui
|
||||
from beets import config
|
||||
from beets.ui import Subcommand
|
||||
from gmusicapi import Musicmanager, Mobileclient
|
||||
from gmusicapi.exceptions import NotLoggedIn
|
||||
import gmusicapi.clients
|
||||
|
||||
|
||||
class Gmusic(BeetsPlugin):
|
||||
def __init__(self):
|
||||
super(Gmusic, self).__init__()
|
||||
# Checks for OAuth2 credentials,
|
||||
# if they don't exist - performs authorization
|
||||
self.m = Musicmanager()
|
||||
if os.path.isfile(gmusicapi.clients.OAUTH_FILEPATH):
|
||||
self.m.login()
|
||||
else:
|
||||
self.m.perform_oauth()
|
||||
super().__init__()
|
||||
|
||||
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'
|
||||
)
|
||||
search.parser.add_option('-t', '--track', dest='track',
|
||||
action='store_true',
|
||||
help='Search by track name')
|
||||
search.parser.add_option('-a', '--artist', dest='artist',
|
||||
action='store_true',
|
||||
help='Search by artist')
|
||||
search.func = self.search
|
||||
return [gupload, search]
|
||||
|
||||
def upload(self, lib, opts, args):
|
||||
items = lib.items(ui.decargs(args))
|
||||
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']
|
||||
email = config['gmusic']['email']
|
||||
password.redact = True
|
||||
email.redact = True
|
||||
# Since Musicmanager doesn't support library management
|
||||
# we need to use mobileclient interface
|
||||
mobile = Mobileclient()
|
||||
try:
|
||||
mobile.login(email.as_str(), password.as_str(),
|
||||
Mobileclient.FROM_MAC_ADDRESS)
|
||||
files = mobile.get_all_songs()
|
||||
except NotLoggedIn:
|
||||
ui.print_(
|
||||
u'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']),
|
||||
file['title'], ui.colorize('red', file['album']))
|
||||
else:
|
||||
if opts.track:
|
||||
self.match(files, args, 'title')
|
||||
else:
|
||||
self.match(files, args, 'artist')
|
||||
|
||||
@staticmethod
|
||||
def match(files, args, search_by):
|
||||
for file in files:
|
||||
if ' '.join(ui.decargs(args)) in file[search_by]:
|
||||
print(file['artist'], file['title'], file['album'])
|
||||
self._log.warning("The 'gmusic' plugin has been removed following the"
|
||||
" shutdown of Google Play Music. Remove the plugin"
|
||||
" from your configuration to silence this warning.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue