コード例 #1
0
    #- Create a temporal playlist with the song-#
    temp_playlist_id = gs.create_playlist(temp_playlist_name, [song_id])
    #-Checking if it was added -#
    playlist_songs = gs.get_playlist_by_id(temp_playlist_id)
    #- Deleting temp playlist -#
    gs.delete_playlist(temp_playlist_id, temp_playlist_name)
    return len(playlist_songs['Songs']) == 1

if len(sys.argv) != 2:
    params()

spotify_file = sys.argv[1]
if not os.path.exists(spotify_file):
    print "'%s' doesn't exist." % spotify_file

gs = GrooveShark()
not_found = []
found = []

if gs.authenticate() is False:
    print "Error authenticating."
    exit(2)

for spotify_url in open(spotify_file):
    spotify_song = helpers.get_song_name(spotify_url)
    if spotify_song is None:
        print "No song info for %s" % spotify_url
        continue
    print "Spotify song: %s, %s, %s" % (spotify_song.get('song'), spotify_song.get('album') or '', spotify_song.get('artist') or '')
    #- Getting search result from cache or getting it and caching it -#
    cache_file = "%s/gs-result-%s" % (CACHE_DIR, helpers.md5(spotify_url))
コード例 #2
0
    print "%s <spotify_songs_file>" % sys.argv[0]
    exit(2)

def etree_to_dict(t):
    d = {t.tag : map(etree_to_dict, t.iterchildren())}
    d.update(('@' + k, v) for k, v in t.attrib.iteritems())
    return d

if len(sys.argv) != 2:
    params()

spotify_file = sys.argv[1]
if not os.path.exists(spotify_file):
    print "'%s' doesn't exist." % spotify_file

gs = GrooveShark()
# Setting bandwidth limit when downloading songs.
gs.set_download_bandwidth_limit(DOWNLOAD_BW_LIMIT)

not_found = []
found = []
found_but_not_downloaded = []
grooveshark_songs_list = []
downloaded_counter = 0
already_downloaded_counter = 0
for spotify_url in open(spotify_file):
    spotify_song = helpers.get_song_name(spotify_url)
    if spotify_song is None:
        print "No song info for %s" % spotify_url
        continue
    print "Spotify song: %s, %s, %s" % (spotify_song.get('song'), spotify_song.get('album'), spotify_song.get('artist'))
コード例 #3
0

def make_sure_dir_exists(dir):
    if not os.path.exists(dir):
        os.makedirs(dir)

if len(sys.argv) != 2:
    params()

try:
    playlist_id = int(sys.argv[1])
except ValueError:
    params()

# Initialize the Groove() object
gs = GrooveShark()
# Setting bandwidth limit when downloading songs.
gs.set_download_bandwidth_limit(DOWNLOAD_BW_LIMIT)

# Get results as a SongList object
playlist = gs.get_playlist(playlist_id)
if 'Name' not in playlist:
    print "\tIt seems there is no a playlist with id: %d" % playlist_id
    exit(2)
playlist_name = playlist['Name']
if len(playlist['Songs']) == 0:
    print "No songs found for the playlist id: %d" % playlist_id
    exit()
print "\nPlaylist: '%s' (%d)\n" % (playlist_name, len(playlist['Songs']))
downloaded_counter = 0
already_downloaded_counter = 0