Skip to content
This repository has been archived by the owner on Dec 10, 2019. It is now read-only.

Commit

Permalink
Update podcast.py
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbailey authored Dec 17, 2016
1 parent 5eebeba commit 6b6d695
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
urls = music[music['YouTube Link'].notnull()]

def getURL(url):
video = pafy.new(url)
video_url = video.getbest().url
filesize = video.getbest().get_filesize()
r = requests.get("http://tinyurl.com/api-create.php?" + urlencode({'url':video_url}))
short_url = r.text
return (short_url, filesize)

try:
video = pafy.new(url)
video_url = video.getbest().url
filesize = video.getbest().get_filesize()
r = requests.get("http://tinyurl.com/api-create.php?" + urlencode({'url':video_url}))
short_url = r.text
return (short_url, filesize)
except:
return ('nourl', 0)

urls['urlfilesize'] = urls['YouTube Link'].apply(getURL)
#urls.to_csv()
rss = '<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" version="2.0"><channel><title>Localhost</title><language>en-US</language>'
Expand Down

0 comments on commit 6b6d695

Please sign in to comment.