-
Notifications
You must be signed in to change notification settings - Fork 7
/
zpravy_hook.py
45 lines (40 loc) · 1.68 KB
/
zpravy_hook.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
#!/usr/bin/python
# -*- coding: utf-8 -*-
####
# 2011-03-28 written by Jan Lana <lana.jan@gmail.org>
#
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# gPodder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# The $subj podcast rss does not contain id and pubdate.
# Because of the missing guid gPodder reports always "no new episodes" for the podcast.
# This hook fix this. The pubdate can be calculated from the audio file url
# and I used the same number as guid.
import gpodder
from gpodder.liblogger import log
import re
import time
# settings
domain = u'http://.*/media/zpravy/(\d+)-cro1_(\d\d)_(\d\d)_(\d\d)_(\d\d).mp3'
class gPodderHooks(object):
def __init__(self):
log('Zpravy extension is initializing.')
def on_episode_save(self, episode):
m = re.search(domain, episode.url)
if m:
ts = time.mktime([int(m.group(1)),int(m.group(2)),int(m.group(3)),int(m.group(4)),int(m.group(5)),0,-1,-1,-1])
episode.pubDate = ts
episode.guid = int(ts)
episode.save()
episode.dv.commit()
log(u'updated pubDate and guid for podcast: (%s/%s)' % (episode.channel.title, episode.title))