forked from gskoljarev/rwnfg
/
rwnfg.py
executable file
·48 lines (36 loc) · 1.78 KB
/
rwnfg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
import iso8601
import requests
from feedgen.feed import FeedGenerator
def insert_paris_attacks_episode(fg):
fe = fg.add_entry()
fe.id('http://exiledonline.com/wnradio/Radio-War-Nerd-Special-Paris-Attacks.mp3')
fe.title('Radio War Nerd, Special Episode -November 16, 2015')
fe.description('Special edition of Radio War Nerd on the Paris ISIS attacks')
fe.enclosure('http://exiledonline.com/wnradio/Radio-War-Nerd-Special-Paris-Attacks.mp3', 0, 'audio/mpeg')
fe.pubdate(iso8601.parse_date('2015-11-16T12:00:00+00:00'))
fg = FeedGenerator()
fg.load_extension('podcast')
fg.podcast.itunes_category('Technology', 'Podcasting')
r = requests.get('https://api.patreon.com/campaigns/157274/posts?filter[is_by_creator]=true&page[count]=100')
patreon_posts = r.json()
entry_list = []
for data in patreon_posts['data']:
post = data['attributes']
if post['post_type'] == 'audio_file' and post['post_file'] is not None:
# insert Paris attacks special episode
if post['published_at'] == '2015-11-15T07:06:53+00:00':
insert_paris_attacks_episode(fg)
fe = fg.add_entry()
fe.id(post['post_file']['url'])
fe.title(post['title'])
fe.description(post['content'])
fe.enclosure(post['post_file']['url'], 0, 'audio/mpeg')
fe.pubdate(iso8601.parse_date(post['published_at']))
fg.title('Radio War Nerd')
fg.podcast.itunes_author('Gary Brecher')
fg.link({'href': 'https://www.patreon.com/radiowarnerd'})
fg.description("The War Nerd Podcast")
fg.logo('https://c10.patreon.com/3/eyJ3Ijo0MDB9/patreon-user/n4H3wobwI3jPQ5ZY5vPlYLmFgn7NZq6K6IbNEI5DvpFYMlozBQB33OZF1kHCjk4y_large_2.jpeg?token-time=2145916800&token-hash=ScHYE7uDDc6w7HeFV1b33guW7-sHpbKVT84yR-HXwJI%3D')
fg.rss_str(pretty=True)
fg.rss_file('rwn.xml')