Created
February 25, 2019 14:13
-
-
Save Zverik/2826d9053ecf17437bc27b1d4988697d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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