Last active
February 29, 2016 04:35
-
-
Save david206/2b0331531d63f4c94aee to your computer and use it in GitHub Desktop.
929 project (www.929.org.il) has great soundcloud page with daily updates. But - it doesn't have rss feed, or Podcast option. In my daily commute I don't have internet connection. So with the following script + Cron job that runs it daily + foldersync to my Android phone - I automaticly download the new sound files and copy them to my phone.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/home/shimon/anaconda2/bin/python | |
# -*- coding: utf-8 -*- | |
from lxml import html | |
import requests | |
import youtube_dl | |
url = 'https://soundcloud.com/929-bible/sets/' | |
base_url = 'https://soundcloud.com' | |
page = requests.get(url) | |
tree = html.fromstring(page.content) | |
articles = tree.xpath('//article[@class="audible"]//a[@itemprop="url"]') | |
hrefs = [article.xpath('@href')[0] for article in articles] | |
titles = [article.xpath('text()')[0] for article in articles] | |
titles_and_hrefs = zip(hrefs, titles) | |
hrefs = [h for h,t in titles_and_hrefs if u'פרק' in t] | |
ydl = youtube_dl.YoutubeDL({'outtmpl': '~/code/fetch929/%(title)s.%(ext)s'}) | |
for href in hrefs: | |
with ydl: | |
ydl.extract_info(base_url + href, download = True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment