Skip to content

Instantly share code, notes, and snippets.

@Zverik
Created February 25, 2019 14:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zverik/2826d9053ecf17437bc27b1d4988697d to your computer and use it in GitHub Desktop.
Save Zverik/2826d9053ecf17437bc27b1d4988697d to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import requests
import json
import re
import statistics
import time
resp = requests.get('https://russiancast.club/data.json')
data = resp.json()
RE_MINUTES = re.compile(r'•\s+(\d+) min')
for p in data:
if not p.get('overcast'):
continue
print(p['title'])
overcast = requests.get(p['overcast'])
m = RE_MINUTES.findall(overcast.text)
if m:
minutes = [float(x) for x in m]
p['duration'] = round(statistics.median(minutes))
else:
print('Could not find duration for {}'.format(p['overcast']))
time.sleep(1)
with open('rupodcast_data_result.json', 'w') as f:
json.dump(data, f, ensure_ascii=False, indent=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment