Ejemplo n.º 1
0
def main():
    logging.basicConfig(stream=sys.stdout, level=logging.DEBUG)

    root = logging.getLogger()
    handler = logging.StreamHandler(sys.stdout)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    handler.setFormatter(formatter)
    root.addHandler(handler)

    pc = PlaylistCreator()
    pc.authenticate()
Ejemplo n.º 2
0
def main(options, args):
    """Run all the things."""
    pc = PlaylistCreator()
    if not pc.authenticated:
        logger.error(
            'You need to authenticate by running `python playlist_helper/authenticate.py` first'
        )
        sys.exit(1)

    user = pc.get_user(username=options['username'],
                       email=options['email'],
                       uid_key=options['uid_key'])
    if user is None:
        print 'No user found for %s %s' % (options['username'],
                                           options['email'])
        exit(1)
    makedirs('dumps/%s' % user['username'])
    dump_comments(user, pc.list_comments(user))
    dump_iterable(user, 'favorite_artists', pc.get_favorite_artists(user))
    dump_iterable(user, 'favorite_labels', pc.get_favorite_labels(user))
    dump_iterable(user, 'favorite_stations', pc.get_favorite_stations(user))

    user['_playlists'] = set()
    for playlist in pc.list_playlists(user):
        dump_playlist(user, playlist)
Ejemplo n.º 3
0
def main(options, args):
    logger.debug('Options: %s', options)
    pc = PlaylistCreator()
    if not pc.authenticated:
        logger.error(
            'You need to authenticate by running ./authenticate.py first')
        sys.exit(0)

    process_txt(pc, options, args)
Ejemplo n.º 4
0
def main(options, args):
    logger.debug('Options: %s', options)
    pc = PlaylistCreator()
    if not pc.authenticated:
        logger.error('You need to authenticate by running `python playlist_helper/authenticate.py` first')
        sys.exit(1)

    user = pc.get_user(username=options['username'], email=options['email'])
    if user is None:
        print 'No user found for %s %s' % (options['username'], options['email'])
        exit(1)

    makedirs('dumps/%s' % user['username'])
    dump_comments(user, pc.list_comments(user))
    dump_iterable(user, 'favorite_artists', pc.get_favorite_artists(user))
    dump_iterable(user, 'favorite_labels', pc.get_favorite_labels(user))
    dump_iterable(user, 'favorite_stations', pc.get_favorite_stations(user))
    for playlist in pc.list_playlists(user):
        dump_playlist(user, playlist)
Ejemplo n.º 5
0
def main(options, args):
    """Run all the things."""
    pc = PlaylistCreator()
    if not pc.authenticated:
        logger.error("You need to authenticate by running `python playlist_helper/authenticate.py` first")
        sys.exit(1)

    user = pc.get_user(username=options["username"], email=options["email"], uid_key=options["uid_key"])
    if user is None:
        print "No user found for %s %s" % (options["username"], options["email"])
        exit(1)
    makedirs("dumps/%s" % user["username"])
    dump_comments(user, pc.list_comments(user))
    dump_iterable(user, "favorite_artists", pc.get_favorite_artists(user))
    dump_iterable(user, "favorite_labels", pc.get_favorite_labels(user))
    dump_iterable(user, "favorite_stations", pc.get_favorite_stations(user))

    user["_playlists"] = set()
    for playlist in pc.list_playlists(user):
        dump_playlist(user, playlist)
		Much more data is exposed by the API, but we don't use it
		'''
		page = 1
		while True:
			d = self.api_call('user.getlovedtracks', user=user, page=page, limit=limit)
			for track in d['lovedtracks']['track']:
				yield (track['artist']['name'], track['name'])

			if page == 1:
				totalPages = int(d['lovedtracks']['@attr']['totalPages'])
			if page >= totalPages:
				break
			page += 1

if __name__ == "__main__":
	if len(sys.argv) < 2:
		print >> sys.stderr, sys.argv[0],'<lastfm username>'
		exit(1)
	username = sys.argv[1]

	lastfm = LastFmLink('1db991b8f9e0b37d79aea6191b4d5cc7')
	rdio = PlaylistCreator()
	if not rdio.authenticated:
		print "You need to authenticate to Rdio. Run ./authenticate.py then try again"
		sys.exit(1)

	print "Getting loved tracks for %s from last.fm" %(username,)
	tracks = list(lastfm.get_loved_tracks(username))
	print "Putting them into playlist '%s' on your Rdio account" % (PLAYLIST_NAME,)
	rdio.make_playlist(PLAYLIST_NAME, PLAYLIST_DESCRIPTION, tracks)
#!/usr/bin/env python

PLAYLIST_NAME = "My Top Rated"
PLAYLIST_DESCRIPTION = "Imported from iTunes"

import sys, logging
from playlistcreator import PlaylistCreator
pc = PlaylistCreator()
if not pc.authenticated:
    print 'You need to authenticate by running ./authenticate.py first'
    sys.exit(0)

logging.basicConfig(level=logging.WARNING)

from ScriptingBridge import *
itunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
playlist = itunes.sources()[0].playlists().objectWithName_(PLAYLIST_NAME)
itunes_tracks = playlist.tracks()
rdio_tracks = []
for track in itunes_tracks:
    #logging.info("%s - %s" % (track.artist().encode("ascii", "replace"), track.name().encode("ascii", "replace")))
    rdio_tracks.append((track.artist(), track.name()))

pc.make_playlist(PLAYLIST_NAME, PLAYLIST_DESCRIPTION, rdio_tracks)
#!/usr/bin/env python

from playlistcreator import PlaylistCreator

pc = PlaylistCreator()
pc.authenticate()
#!/usr/bin/env python

URL='http://hypem.com/popular?ax=1'
PLAYLIST_NAME='Hype Machine Popular'
PLAYLIST_DESC='Hype Machine Popular tracks, see http://hypem.com/popular'

import sys, logging
logging.basicConfig(level=logging.ERROR)
from playlistcreator import PlaylistCreator
pc = PlaylistCreator()
if not pc.authenticated:
  print 'You need to authenticate by running ./authenticate.py first'
  sys.exit(0)

logging.basicConfig(level=logging.ERROR)

# the Hype Machine "popular" page includes a bunch of structures like:
#   <h3 class="track_name"><a>artist name</a> <a>track name</a></h3>
# we can parse that out into (artistname, trackname) pairs

from BeautifulSoup import BeautifulSoup
from urllib import urlopen

bs = BeautifulSoup(urlopen(URL))

tracks = []

for node in [tn for tn in bs.findAll('h3') if tn.get('class') == 'track_name']:
  artist, track = [a.text for a in node.findChildren('a')]
  tracks.append((artist, track))
Ejemplo n.º 10
0
#!/usr/bin/env python

PLAYLIST_NAMES=["My Top Rated"] # Supports a list
PLAYLIST_DESCRIPTION="Imported from iTunes"

import sys, logging
from playlistcreator import PlaylistCreator
from ScriptingBridge import *

pc = PlaylistCreator()
if not pc.authenticated:
  print 'You need to authenticate by running ./authenticate.py first'
  sys.exit(0)

logging.basicConfig(level=logging.WARNING)

for playlist_name in PLAYLIST_NAMES:
  itunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
  playlist = itunes.sources()[0].playlists().objectWithName_(playlist_name)
  itunes_tracks = playlist.tracks()
  rdio_tracks = []
  for track in itunes_tracks:
    #logging.info("%s - %s" % (track.artist().encode("ascii", "replace"), track.name().encode("ascii", "replace")))
    rdio_tracks.append((track.artist(),track.name()))

  if rdio_tracks:
    pc.make_playlist(playlist_name, PLAYLIST_DESCRIPTION, rdio_tracks)

Ejemplo n.º 11
0
#!/usr/bin/env python

URL = 'http://hypem.com/popular?ax=1'
PLAYLIST_NAME = 'Hype Machine Popular'
PLAYLIST_DESC = 'Hype Machine Popular tracks, see http://hypem.com/popular'

import sys, logging
logging.basicConfig(level=logging.ERROR)
from playlistcreator import PlaylistCreator
pc = PlaylistCreator()
if not pc.authenticated:
    print 'You need to authenticate by running ./authenticate.py first'
    sys.exit(0)

logging.basicConfig(level=logging.ERROR)

# the Hype Machine "popular" page includes a bunch of structures like:
#   <h3 class="track_name"><a>artist name</a> <a>track name</a></h3>
# we can parse that out into (artistname, trackname) pairs

from BeautifulSoup import BeautifulSoup
from urllib import urlopen

bs = BeautifulSoup(urlopen(URL))

tracks = []

for node in [tn for tn in bs.findAll('h3') if tn.get('class') == 'track_name']:
    artist, track = [a.text for a in node.findChildren('a')]
    tracks.append((artist, track))
#!/usr/bin/env python

PLAYLIST_NAME="My Top Rated"
PLAYLIST_DESCRIPTION="Imported from iTunes"

import sys, logging
from playlistcreator import PlaylistCreator
pc = PlaylistCreator()
if not pc.authenticated:
  print 'You need to authenticate by running ./authenticate.py first'
  sys.exit(0)

logging.basicConfig(level=logging.WARNING)


from ScriptingBridge import *
itunes = SBApplication.applicationWithBundleIdentifier_("com.apple.iTunes")
playlist = itunes.sources()[0].playlists().objectWithName_(PLAYLIST_NAME)
itunes_tracks = playlist.tracks()
rdio_tracks = []
for track in itunes_tracks:
    #logging.info("%s - %s" % (track.artist().encode("ascii", "replace"), track.name().encode("ascii", "replace")))
    rdio_tracks.append((track.artist(),track.name()))

pc.make_playlist(PLAYLIST_NAME, PLAYLIST_DESCRIPTION, rdio_tracks)