Beispiel #1
0
def main():
    cli = dict((key.lstrip("-<").rstrip(">"), value)
               for key, value in docopt(__doc__).items())

    print_ = safe_print if not cli['quiet'] else lambda *args, **kwargs: None

    mcw = MobileClientWrapper()
    mcw.login(cli['user'], cli['pass'])

    print_("Scanning for songs...\n")
    search_songs = mcw.get_google_songs(filters=cli['filter'],
                                        filter_all=cli['all'])
    search_songs.sort(
        key=lambda song: (song['artist'], song['album'], song['trackNumber']))

    if search_songs:
        if cli['yes'] or raw_input("Display results? (y/n) ").lower() == "y":
            print_()

            for song in search_songs:
                title = song.get('title', "<empty>")
                artist = song.get('artist', "<empty>")
                album = song.get('album', "<empty>")

                print("{0} _by_ {1} _from_ {2} ({3})".format(
                    title, artist, album, song['id']))

            print_()
    else:
        safe_print("\nNo songs found matching query")

    mcw.logout()
    print_("\nAll done!")
def main():
	cli = dict((key.lstrip("-<").rstrip(">"), value) for key, value in docopt(__doc__).items())

	print_ = safe_print if not cli['quiet'] else lambda *args, **kwargs: None

	mcw = MobileClientWrapper()
	mcw.login(cli['user'], cli['pass'])

	print_("Scanning for songs...\n")
	search_songs = mcw.get_google_songs(filters=cli['filter'], filter_all=cli['all'])
	search_songs.sort(key=lambda song: (song['artist'], song['album'], song['trackNumber']))

	if search_songs:
		if cli['yes'] or raw_input("Display results? (y/n) ").lower() == "y":
			print_()

			for song in search_songs:
				title = song.get('title', "<empty>")
				artist = song.get('artist', "<empty>")
				album = song.get('album', "<empty>")

				print("{0} _by_ {1} _from_ {2} ({3})".format(title, artist, album, song['id']))

			print_()
	else:
		safe_print("\nNo songs found matching query")

	mcw.logout()
	print_("\nAll done!")
def main():
    cli = dict((key.lstrip("-<").rstrip(">"), value)
               for key, value in docopt(__doc__).items())

    print_ = safe_print if not cli['quiet'] else lambda *args, **kwargs: None

    mcw = MobileClientWrapper()
    mcw.login(cli['user'], cli['pass'])

    delete_songs = mcw.get_google_songs(filters=cli['filter'],
                                        filter_all=cli['all'])

    if cli['dry-run']:
        print_("Found {0} songs to delete".format(len(delete_songs)))

        if delete_songs:
            safe_print("\nSongs to delete:\n")

            for song in delete_songs:
                safe_print("{0} by {1}".format(song['title'], song['artist']))
        else:
            safe_print("\nNo songs to delete")
    else:
        if delete_songs:
            if cli['yes'] or raw_input(
                    "Are you sure you want to delete {0} songs from Google Music? (y/n) "
                    .format(len(delete_songs))).lower() == "y":
                print_("\nDeleting {0} songs from Google Music\n".format(
                    len(delete_songs)))

                songnum = 0
                total = len(delete_songs)
                pad = len(str(total))

                for song in delete_songs:
                    mcw.api.delete_songs(song['id'])
                    songnum += 1

                    print_(
                        "Deleted {num:>{pad}}/{total} songs from Google Music".
                        format(num=songnum, pad=pad, total=total),
                        end="\r")
                    sys.stdout.flush()

                print_()
            else:
                print_("No songs deleted.")
        else:
            safe_print("\nNo songs to delete")

    mcw.logout()
    print_("\nAll done!")
def main():
	cli = dict((key.lstrip("-<").rstrip(">"), value) for key, value in docopt(__doc__).items())

	print_ = safe_print if not cli['quiet'] else lambda *args, **kwargs: None

	mcw = MobileClientWrapper()
	mcw.login(cli['user'], cli['pass'])

	delete_songs = mcw.get_google_songs(filters=cli['filter'], filter_all=cli['all'])

	if cli['dry-run']:
		print_("Found {0} songs to delete".format(len(delete_songs)))

		if delete_songs:
			safe_print("\nSongs to delete:\n")

			for song in delete_songs:
				safe_print("{0} by {1}".format(song['title'], song['artist']))
		else:
			safe_print("\nNo songs to delete")
	else:
		if delete_songs:
			if cli['yes'] or raw_input("Are you sure you want to delete {0} songs from Google Music? (y/n) ".format(len(delete_songs))).lower() == "y":
				print_("\nDeleting {0} songs from Google Music\n".format(len(delete_songs)))

				songnum = 0
				total = len(delete_songs)
				pad = len(str(total))

				for song in delete_songs:
					mcw.api.delete_songs(song['id'])
					songnum += 1

					print_("Deleted {num:>{pad}}/{total} songs from Google Music".format(num=songnum, pad=pad, total=total), end="\r")
					sys.stdout.flush()

				print_()
			else:
				print_("No songs deleted.")
		else:
			safe_print("\nNo songs to delete")

	mcw.logout()
	print_("\nAll done!")