def get_national_geographic_data():
# Filename with data: .gallery.<currentYear>-<currentMonth>.json
today = datetime.today()
year = str(today.year)
if today.month < 10:
month = '0' + str(today.month)
else:
month = str(today.month)
url = URL00 + year + '-' + month + '.json'
r = requests.get(url)
if r.status_code == 200:
data = r.json()
if 'items' in data:
current_photo = data['items'][0]
# TODO: include preferred image size in configuration
url = current_photo['url'] + current_photo['sizes']['1600']
return dict(url=url,
title=current_photo['title'],
caption=current_photo['caption'],
credit=current_photo['credit'])
return None
ngdownloader.py 文件源码
python
阅读 34
收藏 0
点赞 0
评论 0
评论列表
文章目录