-
Notifications
You must be signed in to change notification settings - Fork 1
/
abgt-add-episode.py
54 lines (43 loc) · 1.97 KB
/
abgt-add-episode.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
49
50
51
52
53
54
#!/usr/bin/env -c python
import sys, os, urllib, datetime, subprocess
from optparse import OptionParser
parser = OptionParser()
parser.add_option('-f', '--filename', dest='filename',
help='ABGT podcast url', action='store')
parser.add_option('-n', '--num', dest='show_num',
help='ABGT number', action='store')
parser.add_option('-g', '--guest', dest='guest_mixer',
help='ABGT guest mixer', action='store')
(options, args) = parser.parse_args()
if options.filename is None or \
options.show_num is None or \
options.guest_mixer is None :
parser.error('Missing arguments')
# get http metadata from remote podcast file
podcast_url = 'http://traffic.libsyn.com/anjunabeats/%s' % options.filename
meta = urllib.urlopen(podcast_url).info()
# get byte length of remote podcast file
length = meta.getheaders('Content-Length')[0]
guid = 'abgt%03d' % int(options.show_num)
author = "Above & Beyond"
title = "#%03d Group Therapy Radio with Above & Beyond" % int(options.show_num)
subtitle = "Episode #%03d / Guest Mix: %s" % (int(options.show_num), options.guest_mixer)
today = datetime.date.today()
friday = today + datetime.timedelta((4 - today.weekday()) % 7)
pubdate = '%s 21:10:00 +0100' % friday.strftime('%a, %d %b %Y')
duration = '02:00:00'
link = 'http://www.aboveandbeyond.nu/radio/abgt%03d' % int(options.show_num)
category = 'Music'
print subprocess.call(['coffee', 'podcast.add.coffee',
'-i', 'shows.json',
'--guid', guid,
'--author', author,
'--title', title,
'--subtitle', subtitle,
'--description', subtitle,
'--pubdate', pubdate,
'--url', podcast_url,
'--length', length,
'--duration', duration,
'--link', link,
'--category', category])