Compare commits

..

No commits in common. "793b615278bf47c4539df1e7a741baddf0c3e40a" and "b88427f05acfa9e079d6691183526828a9c18810" have entirely different histories.

3 changed files with 11 additions and 34 deletions

View File

@ -1,3 +0,0 @@
# autoradio
Auto download of mp3s from podcast feeds using a little Python script.

View File

@ -2,23 +2,9 @@
import feedparser
import argparse
import json
import subprocess
from pathlib import Path
def download_audio(link, destdir):
parts = link.split('/')
ptarget = Path(destdir) / Path(parts[-1])
target = ptarget.resolve()
if target.exists():
print("File already exists, skipping")
else:
args = [ "wget", link, "-o", str(target) ]
print(f"downloading {link}")
subprocess.run(args)
def looks_audio(link):
if 'type' in link:
return link['type'][:5] == 'audio'
@ -39,9 +25,7 @@ def get_latest(url, dir):
print("Multiple audio links")
for s in sounds:
audio_url = s.get('href', '')
if audio_url:
return audio_url
return None
print(audio_url)
def main():
ap = argparse.ArgumentParser("autoradio - download audio from RSS feeds")
@ -54,10 +38,8 @@ def main():
args = ap.parse_args()
with open(args.config, 'r') as cfh:
cf = json.load(cfh)
for name, config in cf['feeds'].items():
for name, config in cf.items():
print(f"Checking {name}")
url = get_latest(config['url'], config['dir'])
if url:
print(f"content = {url}")
download_audio(url, config['dir'])
get_latest(config['url'], config['dir'])

View File

@ -1,12 +1,10 @@
{
"feeds": {
"Utility Fog": {
"url": "https://www.frogworth.com/utilityfog/feed/",
"dir": "./output/UFog"
"dir": "./Utility Fog"
},
"RA Podcast": {
"url": "https://ra.co/xml/podcast.xml",
"dir": "./output/RA"
}
"dir": "./RA Podcast"
}
}