Exemple #1
0
 def create_music_manager(self):
     music_manager = Musicmanager()
     success = music_manager.login(
         oauth_credentials=config.OAUTH_CREDENTIAL_PATH)
     if not success:
         raise Exception("Failed to login music manager")
     print("Logged in music manager")
     return music_manager
def no_client_auth_initially():
    # wc = Webclient()
    # assert_false(wc.is_authenticated())

    mc = Mobileclient()
    assert_false(mc.is_authenticated())

    mm = Musicmanager()
    assert_false(mm.is_authenticated())
def gm_login(credentials):
    if not hasattr(gm_login, 'api'):
        # Stored api connection for multiple upload support without re-authing every time
        gm_login.api = Musicmanager(debug_logging=VERBOSE)
    # Credential pass through is working here
    if not gm_login.api.is_authenticated():
        if not gm_login.api.login(
                OAUTH_FILEPATH if not credentials else credentials):
            try:
                gm_login.api.perform_oauth()
            except:
                print("Unable to login with specified oauth code.")
            gm_login.api.login(
                OAUTH_FILEPATH if not credentials else credentials)
    return gm_login.api
    def __init__(self):
        super(GooglePlayMusicPlugin, self).__init__()

        # Get configurations
        self.config.add({
            'auto-upload': True,
            #'auto-delete': True,
            'enable-matching': True,
            'uploader-id': None
        })
        self.auto_upload = self.config['auto-upload'].get(bool)
        #self.auto_delete = self.config['auto-delete'].get(bool)
        self.enable_matching = self.config['enable-matching'].get(bool)
        self.uploader_id = self.config['uploader-id'].get()

        # Initialize gmusicapi
        self.mm = Musicmanager(debug_logging=False)
        self.mm.logger.addHandler(logging.NullHandler())
        try:
            if not self.mm.login(oauth_credentials=OAUTH_FILEPATH, uploader_id=self.uploader_id):
                try:
                    self.mm.perform_oauth()
                except e:
                    self._log.error("Error: Unable to login with specified oauth code.")
                    raise e
                self.mm.login(oauth_credentials=OAUTH_FILEPATH, uploader_id=self.uploader_id)
        except (OSError, ValueError) as e:
            self._log.error("Error: Couldn't log in.")
            raise e

        if not self.authenticated:
            self._log.error("Error: Couldn't log in.")

        # Register listeners
        if self.auto_upload:
            self.register_listener('item_imported', self.on_item_imported)
            self.register_listener('album_imported', self.on_album_imported)
Exemple #5
0
    '--quiet',
    action='store_true',
    default=False,
    help=
    'Don\'t output status messages\n-l,--log will display gmusicapi warnings\n-d,--dry-run will display song list'
)
parser.add_argument(
    'input',
    nargs='*',
    default='.',
    help=
    'Files, directories, or glob patterns to upload\nDefaults to current directory if none given'
)
opts = parser.parse_args()

MM = Musicmanager(debug_logging=opts.log)

_print = print if not opts.quiet else lambda *a, **k: None


def do_auth():
    """
	Authenticates the MM client.
	"""

    attempts = 0

    oauth_file = os.path.join(os.path.dirname(OAUTH_FILEPATH),
                              opts.cred + '.cred')

    # Attempt to login. Perform oauth only when necessary.
Exemple #6
0
    def __init__(self, log=False, quiet=False):
        self.api = Musicmanager(debug_logging=log)
        self.api.logger.addHandler(logging.NullHandler())

        self.print_ = safe_print if not quiet else lambda *args, **kwargs: None