Mercurial > feed-push
comparison feed-push @ 33:adde3e451237 draft
use feed link as id when available
Signed-off-by: Changaco <changaco ατ changaco δοτ net>
author | Changaco <changaco ατ changaco δοτ net> |
---|---|
date | Sun, 05 Aug 2012 15:06:00 +0200 |
parents | 5348758c622d |
children | 030e8b24f8b7 |
comparison
equal
deleted
inserted
replaced
32:5348758c622d | 33:adde3e451237 |
---|---|
158 feed_fd = open(path) | 158 feed_fd = open(path) |
159 except IOError as e: | 159 except IOError as e: |
160 return log('failed to open "'+path+'": '+str(e)) | 160 return log('failed to open "'+path+'": '+str(e)) |
161 feed = feedparser.parse(feed_fd.read()) | 161 feed = feedparser.parse(feed_fd.read()) |
162 feed_fd.close() | 162 feed_fd.close() |
163 id_cache = state['id_cache'] | |
164 feed_id = feed.feed.get('link', path) | |
165 if feed_id != path and path in id_cache: | |
166 id_cache[feed_id] = id_cache.pop(path) | |
163 i = 0 | 167 i = 0 |
164 for entry in reversed(feed.entries): | 168 for entry in reversed(feed.entries): |
165 if entry.id in state['id_cache'].get(path, []) or \ | 169 if entry.id in id_cache.get(feed_id, []) or \ |
166 not global_args.flood and calendar.timegm(entry.published_parsed) < time.time() - 86400: | 170 not global_args.flood and calendar.timegm(entry.published_parsed) < time.time() - 86400: |
167 continue | 171 continue |
168 i += 1 | 172 i += 1 |
169 for feed_path_to_commands in config_to_feed_paths_to_commands.values(): | 173 for feed_path_to_commands in config_to_feed_paths_to_commands.values(): |
170 for cmd in feed_path_to_commands.get(path, []): | 174 for cmd in feed_path_to_commands.get(path, []): |
171 run_command(format_cmd(cmd, feed=feed.feed, entry=entry), entry.content[0].value) | 175 run_command(format_cmd(cmd, feed=feed.feed, entry=entry), entry.content[0].value) |
172 state['id_cache'][path] = [entry.id for entry in feed.entries] | 176 id_cache[feed_id] = [entry.id for entry in feed.entries] |
173 save_state() | 177 save_state() |
174 if i == 0: | 178 if i == 0: |
175 log('no new entry in %s' % path) | 179 log('no new entry in %s' % path) |
176 else: | 180 else: |
177 ignore_event(path, event) | 181 ignore_event(path, event) |