Barbacoa los Domingos

martes, marzo 24, 2009

 

Ver nuevos albums de blogs musicales


Solo falta poner el downloader



#!/usr/bin/env python

import urllib
import feedparser
import sgmllib
import pylast

lastfm_api_key =
lastfm_api_secret =
lastfm_session_key =

site_feeds = ["http://feeds2.feedburner.com/nodatatv",
"http://elblogdelsilencio.blogspot.com/feeds/posts/default",
"http://independent-world.blogspot.com/feeds/posts/default",
"http://supershock666.blogspot.com/feeds/posts/default",
]

class MyParser(sgmllib.SGMLParser):
"A simple parser class."

def parse(self, s):
"Parse the given string 's'."
self.feed(s)
self.close()

def __init__(self, verbose=0):
"Initialise an object, passing 'verbose' to the superclass."

sgmllib.SGMLParser.__init__(self, verbose)
self.hyperlinks = []

def start_a(self, attributes):
"Process a hyperlink and its 'attributes'."

for name, value in attributes:
if name == "href":
self.hyperlinks.append(value)

def get_hyperlinks(self):
"Return the list of hyperlinks."
return self.hyperlinks

for site_feed in site_feeds:

parse_feed = feedparser.parse(site_feed)
feed_title = parse_feed.feed.title
last_entry = parse_feed.entries[0]
last_entry_title = last_entry.title
last_entry_link = last_entry.link

link_url = urllib.urlopen(last_entry_link)
read_link_url = link_url.read()
link_url.close()

myparser = MyParser()
myparser.parse(read_link_url)

print "\n\nWatching %s" % feed_title

try:
split = last_entry_title.split('-')

if len(split) != 2:
split = last_entry_title.split('/')
artist = last_entry_title.split('/')[0]
album = last_entry_title.split('/')[1]

else:
artist = last_entry_title.split('-')[0]
album = last_entry_title.split('-')[1]

print "Artist: %s" % artist
print "Album: %s" % album

for link in myparser.get_hyperlinks():
if '.rar' in link:
print "Link: %s" % link
elif '.zip' in link:
print "Link: %s" % link
elif 'mediafire' in link:
print "Link: %s" % link

except IndexError:
artist = last_entry_title
print "Artist: %s" % artist

for link in myparser.get_hyperlinks():
if '.rar' in link:
print "Link: %s" % link
elif '.zip' in link:
print "Link: %s" % link
elif 'mediafire' in link:
print "Link: %s" % link

try:
lastfm_info = pylast.Artist(artist, lastfm_api_key, lastfm_api_secret, lastfm_session_key)
print "Similar Artists (according to lastfm):\n"

for similar_artist in lastfm_info.get_similar()[0:10]:
print similar_artist

except (pylast.ServiceException, UnicodeDecodeError), error:
print "It seems %s isn't a real artist" % lastfm_info
pass


Archivos

diciembre 2007   enero 2008   febrero 2008   marzo 2008   mayo 2008   marzo 2009  

This page is powered by Blogger. Isn't yours?

Suscribirse a Entradas [Atom]