summaryrefslogtreecommitdiff
blob: f4df6f0769a936b358bfb895dd358c8fab3a959c (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
David Reitz writes:

I created this so that I could specify a feedurl parameter in the config file,
which allows me to use the public RSS feeds at showRSS (http://showrss.karmorra.info/).
This patch will ONLY work for seasonepisode. I made no modifications for other types.

Simply apply this patch and then modify your config like so:

[Weeds]
feedurl = http://showrss.karmorra.info/feeds/68.rss
episode = 4
season = 5
show_type = seasonepisode
human_name = Weeds

https://sourceforge.net/tracker/index.php?func=detail&aid=2818315&group_id=203642&atid=986413

--- pytvshows.orig	2009-06-20 15:46:23.000000000 -0400
+++ pytvshows	2009-07-07 20:41:39.000000000 -0400
@@ -83,11 +83,14 @@ config = {
     'output_dir2': None,
     'quality_matches': {
         "[HD": 1,
+        "HDTV": 1,
         "[DSRIP": 1,
         "[TVRIP": 1,
         "[PDTV": 1,
         "[DVD": 1,
         "[HR": 2,
+        "720p": 3,
+        "720P": 3,
         "[720p": 3,
         "[720P": 3,
     },
@@ -189,6 +192,7 @@ class Show(object):
         self.show_type = args['show_type']
         self.season = args['season']
         self.episode = args['episode']
+	self.feedurl = args['feedurl']
         #YYYY-MM-DD HH:MM:SS
         if args['date']:
             self.date = datetime.datetime(*(time.strptime(
@@ -290,7 +294,10 @@ class Show(object):
     
     def _get_rss_feed(self):
         """Gets the feedparser object."""
-        url = config['feed'] % self.exact_name
+	if self.feedurl:
+	  url = self.feedurl
+	else:
+          url = config['feed'] % self.exact_name
         if config['verbose']:
             print "Downloading and processing %s..." % url
         r = feedparser.parse(url)
@@ -335,50 +342,21 @@ class Show(object):
         if not self.rss:
             return False
         episodes = {}
-        for episode in self.rss['entries']:
-            if self.show_type == 'seasonepisode':
-                r = re.compile('Season\s*: ([0-9]*?);')
-                season_match = r.search(episode.description)
-                r = re.compile('Episode\s*:\ ([0-9]*?)$')
-                episode_match = r.search(episode.description)
-                if not season_match or not episode_match:
-                    # This might be a special with a title
-                    r = re.compile('Show\s*Title\s*:\s*(.*?);')
-                    title_match = r.search(episode.description)
-                    if title_match and title_match.group(1) != 'n/a' \
-                                        and title_match.group(1) != '':
-                        title = title_match.group(1)
-                        if config["verbose"]:
-                            print "Found episode with title %s and no " \
-                            "season or episode in seasonepisode show." % title
-                        quality = 0
-                        for key, value in config["quality_matches"].items():
-                            if key in episode.title:
-                                quality = value
-                                break
-                        date = datetime.datetime(* episode.updated_parsed[:6])
-                        obj = EpisodeWithTitle(
-                            self,
-                            episode.link,
-                            date,
-                            title,
-                            quality)
-                        last_key = 0
-                        for key in episodes.keys():
-                            if key[0] == 0 and key[1] > last_key:
-                                last_key = key[1]
-                        episodes[0, last_key] = [obj]
-                    elif not self.ignoremissingdetails:
-                        print >> warn, 'W: Could not match season and/or ' \
-                            'episode in %s' % episode.description
-                else:
+	# we've defined a feedurl in the config file...
+	if self.feedurl:
+	    for episode in self.rss['entries']:
+	        if self.show_type == 'seasonepisode':
+		    r = re.compile('S([0-9]+)E([0-9]+)')
+		    match = r.search( episode.title )
+		    season_num = int(match.group(1))
+		    episode_num = int(match.group(2))
+                    if config["verbose"]:
+		        print "Found Show:  Season %i, Episode %i" % (season_num, episode_num)
                     quality = 0
                     for key, value in config["quality_matches"].items():
                         if key in episode.title:
                             quality = value
                             break
-                    season_num = int(season_match.group(1))
-                    episode_num = int(episode_match.group(1))
                     if season_num != 0 and episode_num != 0:
                         obj = EpisodeWithSeasonAndEpisode(
                             self,
@@ -394,57 +372,117 @@ class Show(object):
                     elif config['verbose']:
                         print 'Season or episode number is 0 in %s' \
                                 % episode.description
-            elif self.show_type == 'date':
-                r = re.compile('Episode\s*Date:\s*([0-9\-]+)$')
-                date_match = r.search(episode.description)
-                if not date_match:
-                    if not self.ignoremissingdetails:
-                        print >>warn, 'W: Could not match date in %s' % \
-                            episode.description
-                else:
+	else:
+            for episode in self.rss['entries']:
+                if self.show_type == 'seasonepisode':
+                    r = re.compile('Season\s*: ([0-9]*?);')
+                    season_match = r.search(episode.description)
+                    r = re.compile('Episode\s*:\ ([0-9]*?)$')
+                    episode_match = r.search(episode.description)
+                    if not season_match or not episode_match:
+                        # This might be a special with a title
+                        r = re.compile('Show\s*Title\s*:\s*(.*?);')
+                        title_match = r.search(episode.description)
+                        if title_match and title_match.group(1) != 'n/a' \
+                                            and title_match.group(1) != '':
+                            title = title_match.group(1)
+                            if config["verbose"]:
+                                print "Found episode with title %s and no " \
+                                "season or episode in seasonepisode show." % title
+                            quality = 0
+                            for key, value in config["quality_matches"].items():
+                                if key in episode.title:
+                                    quality = value
+                                    break
+                            date = datetime.datetime(* episode.updated_parsed[:6])
+                            obj = EpisodeWithTitle(
+                                self,
+                                episode.link,
+                                date,
+                                title,
+                                quality)
+                            last_key = 0
+                            for key in episodes.keys():
+                                if key[0] == 0 and key[1] > last_key:
+                                    last_key = key[1]
+                            episodes[0, last_key] = [obj]
+                        elif not self.ignoremissingdetails:
+                            print >> warn, 'W: Could not match season and/or ' \
+                                'episode in %s' % episode.description
+                    else:
+                        quality = 0
+                        for key, value in config["quality_matches"].items():
+                            if key in episode.title:
+                                quality = value
+                                break
+                        season_num = int(season_match.group(1))
+                        episode_num = int(episode_match.group(1))
+                        if season_num != 0 and episode_num != 0:
+                            obj = EpisodeWithSeasonAndEpisode(
+                                self,
+                                episode.link,
+                                datetime.datetime(* episode.updated_parsed[:6]),
+                                season_num,
+                                episode_num,
+                                quality)
+                            try:
+                                episodes[season_num, episode_num].append(obj)
+                            except KeyError:
+                                episodes[season_num, episode_num] = [obj]
+                        elif config['verbose']:
+                            print 'Season or episode number is 0 in %s' \
+                                    % episode.description
+                elif self.show_type == 'date':
+                    r = re.compile('Episode\s*Date:\s*([0-9\-]+)$')
+                    date_match = r.search(episode.description)
+                    if not date_match:
+                        if not self.ignoremissingdetails:
+                            print >>warn, 'W: Could not match date in %s' % \
+                                episode.description
+                    else:
+                        quality = 0
+                        for key, value in config["quality_matches"].items():
+                            if key in episode.title:
+                                quality = value
+                                break
+                        date = datetime.datetime(*(time.strptime(
+                            date_match.group(1), "%Y-%m-%d")[0:6])).date()
+                        obj = EpisodeWithDate(
+                            self,
+                            episode.link,
+                            datetime.datetime(* episode.updated_parsed[:6]),
+                            date,
+                            quality)
+                        try:
+                            episodes[date].append(obj)
+                        except KeyError:
+                            episodes[date] = [obj]
+                elif self.show_type == 'time':
+                    r = re.compile('Show\s*Title\s*:\s*(.*?);')
+                    title_match = r.search(episode.description)
+                    if not title_match:
+                        if not self.ignoremissingdetails:
+                            print >>warn, 'W: Could not match title in %s' % \
+                                episode.description
+                        title = ""
+                    else:
+                        title = title_match.group(1)
                     quality = 0
                     for key, value in config["quality_matches"].items():
                         if key in episode.title:
                             quality = value
                             break
-                    date = datetime.datetime(*(time.strptime(
-                        date_match.group(1), "%Y-%m-%d")[0:6])).date()
-                    obj = EpisodeWithDate(
+                    date = datetime.datetime(* episode.updated_parsed[:6])
+                    obj = EpisodeWithTitle(
                         self,
                         episode.link,
-                        datetime.datetime(* episode.updated_parsed[:6]),
                         date,
+                        title,
                         quality)
                     try:
                         episodes[date].append(obj)
                     except KeyError:
                         episodes[date] = [obj]
-            elif self.show_type == 'time':
-                r = re.compile('Show\s*Title\s*:\s*(.*?);')
-                title_match = r.search(episode.description)
-                if not title_match:
-                    if not self.ignoremissingdetails:
-                        print >>warn, 'W: Could not match title in %s' % \
-                            episode.description
-                    title = ""
-                else:
-                    title = title_match.group(1)
-                quality = 0
-                for key, value in config["quality_matches"].items():
-                    if key in episode.title:
-                        quality = value
-                        break
-                date = datetime.datetime(* episode.updated_parsed[:6])
-                obj = EpisodeWithTitle(
-                    self,
-                    episode.link,
-                    date,
-                    title,
-                    quality)
-                try:
-                    episodes[date].append(obj)
-                except KeyError:
-                    episodes[date] = [obj]
         self.episodes = episodes
         return episodes
 
@@ -597,6 +635,7 @@ def main(argv=None):
             'date': None,
             'time': None, 
             'ignoremissingdetails': False,
+	    'feedurl': None,
         }
         for key in args.keys():
             if f.has_option(exact_name, key):