X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=parse.py;h=b5032b3f014517acc881a9af99949c1347f53c03;hb=e72e03b20a35d116f4a8b55b05e6dd229d7df4fb;hp=aa725d3bf35f28daa6b454ef9867732363aa09a9;hpb=476b8628e1965f9714e3d7f4148dfbc3c6f249e9;p=i_like_pandora.git diff --git a/parse.py b/parse.py index aa725d3..b5032b3 100644 --- a/parse.py +++ b/parse.py @@ -1,12 +1,25 @@ -from BeautifulSoup import BeautifulSoup -import urllib -import re +__author__ = ("Dylan Lloyd ") +__license__ = "BSD" + +# SETTINGS USER = 'alphabethos' +# END OF SETTINGS + +import urllib +from BeautifulSoup import BeautifulSoup def fetch_stations(user): - tokens = ['0081d3c8e037f4c32a44f01b1701dd31466957fc96e4da2e', 'db592464bbca03e7664b1093336f121ce8c7587b2172781c'] - return tokens + stations = [] + page = urllib.urlopen('http://www.pandora.com/favorites/profile_tablerows_station.vm?webname=' + USER) + page = BeautifulSoup(page) + table = page.findAll('div', attrs={'class':'station_table_row'}) + for row in table: + if row.find('a'): + for attr, value in row.find('a').attrs: + if attr == 'href': + stations.append(value[10:]) + return stations def fetch_tracks(stations): for station in stations: @@ -34,4 +47,3 @@ def main(): if __name__ == "__main__": main() -