X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=likes_pandora.py;h=cd066e880a58ad79a68885c9a9b001d3c3a59012;hb=8e57a07a7ec649864e8152b8d3e1e1a1e5fba14f;hp=900c4616e4815cd7021e954939063ef102177a96;hpb=39bcf5bc4822f373520b71378d1fcc0ba20f61ed;p=i_like_pandora.git diff --git a/likes_pandora.py b/likes_pandora.py index 900c461..cd066e8 100644 --- a/likes_pandora.py +++ b/likes_pandora.py @@ -23,6 +23,7 @@ import shlex, subprocess import re def fetch_stations(user): + """ This takes a pandora username and returns the a list of the station tokens that the user is subscribed to. """ stations = [] page = urllib.urlopen('http://www.pandora.com/favorites/profile_tablerows_station.vm?webname=' + USER) page = BeautifulSoup(page) @@ -35,6 +36,9 @@ def fetch_stations(user): return stations def fetch_tracks(stations): + """ Takes a list of station tokens and returns a list of youtube search urls. + What this should really do is just return the Title + Artist strings. + """ search_urls = [] for station in stations: page = urllib.urlopen('http://www.pandora.com/favorites/station_tablerows_thumb_up.vm?token=' + station + '&sort_col=thumbsUpDate') @@ -58,6 +62,9 @@ def fetch_tracks(stations): return search_urls def fetch_search_video_ids(search_urls): + """ This takes a list of youtube search urls and tries to find the first result. It returns a list of youtube video ids. + It really should take a list of ids instead. + """ video_list = [] for url in search_urls: page = urllib.urlopen(url) @@ -82,7 +89,7 @@ def check_for_existing(): return videolist def fetch_videos(videolist): - """ Uses subprocess to trigger a download using youtube-dl of the list created earlier. """ + """ Uses subprocess to trigger a download using youtube-dl of the list created earlier, and triggers notifications if enabled. """ os.chdir(DIR) args = shlex.split(YT_DL + ' ' + YT_OPT) if NOTIFICATIONS: regex = re.compile("\[download\] Destination: (.+)")