def main(): cli = dict((key.lstrip("-<").rstrip(">"), value) for key, value in docopt(__doc__).items()) if cli['quiet']: logger.setLevel(QUIET) else: logger.setLevel(logging.INFO) mcw = MobileClientWrapper(enable_logging=cli['log']) mcw.login(username=cli['user'], password=cli['pass'], android_id=cli['android-id']) if not mcw.is_authenticated: sys.exit() include_filters = [ tuple(filt.split(':', 1)) for filt in cli['include-filter'] ] exclude_filters = [ tuple(filt.split(':', 1)) for filt in cli['exclude-filter'] ] logger.info("Scanning for songs...\n") search_results, _ = mcw.get_google_songs(include_filters=include_filters, exclude_filters=exclude_filters, all_includes=cli['all-includes'], all_excludes=cli['all-excludes']) search_results.sort(key=lambda song: (song.get('artist'), song.get( 'album'), song.get('trackNumber'))) if search_results: confirm = cli['yes'] or cli['quiet'] logger.info("") if confirm or input("Display {} results? (y/n) ".format( len(search_results))) in ("y", "Y"): logger.log(QUIET, "") for song in search_results: title = song.get('title', "<empty>") artist = song.get('artist', "<empty>") album = song.get('album', "<empty>") song_id = song['id'] logger.log( QUIET, "{0} -- {1} -- {2} ({3})".format(title, artist, album, song_id)) else: logger.info("\nNo songs found matching query") mcw.logout() logger.info("\nAll done!")
def main(): cli = dict((key.lstrip("-<").rstrip(">"), value) for key, value in docopt(__doc__).items()) if cli['quiet']: logger.setLevel(QUIET) else: logger.setLevel(logging.INFO) mcw = MobileClientWrapper(enable_logging=cli['log']) mcw.login(username=cli['user'], password=cli['pass'], android_id=cli['android-id']) if not mcw.is_authenticated: sys.exit() include_filters = [tuple(filt.split(':', 1)) for filt in cli['include-filter']] exclude_filters = [tuple(filt.split(':', 1)) for filt in cli['exclude-filter']] logger.info("Scanning for songs...\n") search_results, _ = mcw.get_google_songs( include_filters=include_filters, exclude_filters=exclude_filters, all_includes=cli['all-includes'], all_excludes=cli['all-excludes'] ) search_results.sort(key=lambda song: (song.get('artist'), song.get('album'), song.get('trackNumber'))) if search_results: confirm = cli['yes'] or cli['quiet'] logger.info("") if confirm or input("Display {} results? (y/n) ".format(len(search_results))) in ("y", "Y"): logger.log(QUIET, "") for song in search_results: title = song.get('title', "<empty>") artist = song.get('artist', "<empty>") album = song.get('album', "<empty>") song_id = song['id'] logger.log(QUIET, "{0} -- {1} -- {2} ({3})".format(title, artist, album, song_id)) else: logger.info("\nNo songs found matching query") mcw.logout() logger.info("\nAll done!")
def main(): if os.name == 'nt': sys.argv = win32_unicode_argv() else: sys.argv = [arg.decode(sys.stdin.encoding) for arg in sys.argv] cli = dict((key.lstrip("-<").rstrip(">"), value) for key, value in docopt(__doc__).items()) if cli['quiet']: logger.setLevel(QUIET) else: logger.setLevel(logging.INFO) mcw = MobileClientWrapper() mcw.login(cli['user'], cli['pass'], cli['android-id']) include_filters = [tuple(filt.split(':', 1)) for filt in cli['include-filter']] exclude_filters = [tuple(filt.split(':', 1)) for filt in cli['exclude-filter']] logger.info("Scanning for songs...\n") search_results, _ = mcw.get_google_songs(include_filters, exclude_filters, cli['include-all'], cli['exclude-all']) search_results.sort(key=lambda song: (song.get('artist'), song.get('album'), song.get('trackNumber'))) if search_results: confirm = cli['yes'] or cli['quiet'] logger.info("") if confirm or raw_input("Display {} results? (y/n) ".format(len(search_results))) in ("y", "Y"): logger.log(QUIET, "") for song in search_results: title = song.get('title', "<empty>") artist = song.get('artist', "<empty>") album = song.get('album', "<empty>") song_id = song['id'] logger.log(QUIET, "{0} -- {1} -- {2} ({3})".format(title, artist, album, song_id)) else: logger.info("\nNo songs found matching query") mcw.logout() logger.info("\nAll done!")
def main(): if os.name == 'nt': sys.argv = win32_unicode_argv() else: sys.argv = [arg.decode(sys.stdin.encoding) for arg in sys.argv] cli = dict((key.lstrip("-<").rstrip(">"), value) for key, value in docopt(__doc__).items()) if cli['quiet']: logger.setLevel(QUIET) else: logger.setLevel(logging.INFO) mcw = MobileClientWrapper() mcw.login(cli['user'], cli['pass'], cli['android-id']) include_filters = [tuple(filt.split(':', 1)) for filt in cli['include-filter']] exclude_filters = [tuple(filt.split(':', 1)) for filt in cli['exclude-filter']] songs_to_delete, _ = mcw.get_google_songs(include_filters, exclude_filters, cli['include-all'], cli['exclude-all']) if cli['dry-run']: logger.info("Found {0} songs to delete".format(len(songs_to_delete))) if songs_to_delete: logger.info("\nSongs to delete:\n") for song in songs_to_delete: title = song.get('title', "<empty>") artist = song.get('artist', "<empty>") album = song.get('album', "<empty>") song_id = song['id'] logger.log(QUIET, "{0} -- {1} -- {2} ({3})".format(title, artist, album, song_id)) else: logger.info("\nNo songs to delete") else: if songs_to_delete: confirm = cli['yes'] or cli['quiet'] logger.info("") if confirm or raw_input("Are you sure you want to delete {0} song(s) from Google Music? (y/n) ".format(len(songs_to_delete))) in ("y", "Y"): logger.info("\nDeleting {0} songs from Google Music\n".format(len(songs_to_delete))) songnum = 0 total = len(songs_to_delete) pad = len(str(total)) for song in songs_to_delete: mcw.api.delete_songs(song['id']) songnum += 1 title = song.get('title', "<empty>") artist = song.get('artist', "<empty>") album = song.get('album', "<empty>") song_id = song['id'] logger.debug("Deleting {0} -- {1} -- {2} ({3})".format(title, artist, album, song_id)) logger.info("Deleted {num:>{pad}}/{total} song(s) from Google Music".format(num=songnum, pad=pad, total=total)) else: logger.info("\nNo songs deleted.") else: logger.info("\nNo songs to delete") mcw.logout() logger.info("\nAll done!")
def main(): cli = dict((key.lstrip("-<").rstrip(">"), value) for key, value in docopt(__doc__).items()) if cli["quiet"]: logger.setLevel(QUIET) else: logger.setLevel(logging.INFO) mcw = MobileClientWrapper(enable_logging=cli["log"]) mcw.login(cli["user"], cli["pass"], cli["android-id"]) include_filters = [tuple(filt.split(":", 1)) for filt in cli["include-filter"]] exclude_filters = [tuple(filt.split(":", 1)) for filt in cli["exclude-filter"]] songs_to_delete, _ = mcw.get_google_songs( include_filters, exclude_filters, cli["all-includes"], cli["all-excludes"] ) if cli["dry-run"]: logger.info("Found {0} songs to delete".format(len(songs_to_delete))) if songs_to_delete: logger.info("\nSongs to delete:\n") for song in songs_to_delete: title = song.get("title", "<empty>") artist = song.get("artist", "<empty>") album = song.get("album", "<empty>") song_id = song["id"] logger.log(QUIET, "{0} -- {1} -- {2} ({3})".format(title, artist, album, song_id)) else: logger.info("\nNo songs to delete") else: if songs_to_delete: confirm = cli["yes"] or cli["quiet"] logger.info("") if confirm or input( "Are you sure you want to delete {0} song(s) from Google Music? (y/n) ".format(len(songs_to_delete)) ) in ("y", "Y"): logger.info("\nDeleting {0} songs from Google Music\n".format(len(songs_to_delete))) songnum = 0 total = len(songs_to_delete) pad = len(str(total)) for song in songs_to_delete: mcw.api.delete_songs(song["id"]) songnum += 1 title = song.get("title", "<empty>") artist = song.get("artist", "<empty>") album = song.get("album", "<empty>") song_id = song["id"] logger.debug("Deleting {0} -- {1} -- {2} ({3})".format(title, artist, album, song_id)) logger.info( "Deleted {num:>{pad}}/{total} song(s) from Google Music".format( num=songnum, pad=pad, total=total ) ) else: logger.info("\nNo songs deleted.") else: logger.info("\nNo songs to delete") mcw.logout() logger.info("\nAll done!")
def main(): cli = dict((key.lstrip("-<").rstrip(">"), value) for key, value in docopt(__doc__).items()) if cli['quiet']: logger.setLevel(QUIET) else: logger.setLevel(logging.INFO) mcw = MobileClientWrapper(enable_logging=cli['log']) mcw.login(username=cli['user'], password=cli['pass'], android_id=cli['android-id']) if not mcw.is_authenticated: sys.exit() include_filters = [ tuple(filt.split(':', 1)) for filt in cli['include-filter'] ] exclude_filters = [ tuple(filt.split(':', 1)) for filt in cli['exclude-filter'] ] songs_to_delete, _ = mcw.get_google_songs(include_filters=include_filters, exclude_filters=exclude_filters, all_includes=cli['all-includes'], all_excludes=cli['all-excludes']) if cli['dry-run']: logger.info("Found {0} songs to delete".format(len(songs_to_delete))) if songs_to_delete: logger.info("\nSongs to delete:\n") for song in songs_to_delete: title = song.get('title', "<empty>") artist = song.get('artist', "<empty>") album = song.get('album', "<empty>") song_id = song['id'] logger.log( QUIET, "{0} -- {1} -- {2} ({3})".format(title, artist, album, song_id)) else: logger.info("\nNo songs to delete") else: if songs_to_delete: confirm = cli['yes'] or cli['quiet'] logger.info("") if confirm or input( "Are you sure you want to delete {0} song(s) from Google Music? (y/n) " .format(len(songs_to_delete))) in ("y", "Y"): logger.info("\nDeleting {0} songs from Google Music\n".format( len(songs_to_delete))) songnum = 0 total = len(songs_to_delete) pad = len(str(total)) for song in songs_to_delete: mcw.api.delete_songs(song['id']) songnum += 1 title = song.get('title', "<empty>") artist = song.get('artist', "<empty>") album = song.get('album', "<empty>") song_id = song['id'] logger.debug("Deleting {0} -- {1} -- {2} ({3})".format( title, artist, album, song_id)) logger.info( "Deleted {num:>{pad}}/{total} song(s) from Google Music" .format(num=songnum, pad=pad, total=total)) else: logger.info("\nNo songs deleted.") else: logger.info("\nNo songs to delete") mcw.logout() logger.info("\nAll done!")