engine.log.info('Login to <b>lostfilm.tv</b>') try: self.tracker.login(username, password) with DBSession() as db: cred = db.query(LostFilmTVCredentials).first() cred.c_uid = self.tracker.c_uid cred.c_pass = self.tracker.c_pass cred.c_usess = self.tracker.c_usess except Exception as e: if engine: engine.log.failed('Login to <b>lostfilm.tv</b> failed: {0}'.format(e.message)) return self.tracker.verify() @staticmethod def _get_torrent_info(series): if series.season and series.episode: info = "S%02dE%02d" % (series.season, series.episode) elif series.season: info = "S%02d" % series.season else: info = None return { "id": series.id, "name": series.display_name, "url": series.url, "info": info, "last_update": series.last_update.isoformat() if series.last_update else None } register_plugin('tracker', PLUGIN_NAME, LostFilmPlugin(), upgrade=upgrade)
except Exception as e: if engine: engine.log.failed( 'Login to <b>lostfilm.tv</b> failed: {0}'.format( e.message)) return self.tracker.verify() @staticmethod def _get_torrent_info(series): if series.season and series.episode: info = "S%02dE%02d" % (series.season, series.episode) elif series.season: info = "S%02d" % series.season else: info = None return { "id": series.id, "name": series.display_name, "url": series.url, "info": info, "last_update": series.last_update.isoformat() if series.last_update else None } register_plugin('tracker', PLUGIN_NAME, LostFilmPlugin(), upgrade=upgrade)
return False return { "name": torrent['name'], "date_added": datetime.fromtimestamp(torrent['time_added']) } # TODO add path to download def add_torrent(self, torrent): path_to_download = None client = self._get_client() if not client: return False client.connect() result = client.call("core.add_torrent_file", None, base64.encodestring(torrent), None) return result def remove_torrent(self, torrent_hash): client = self._get_client() if not client: return False client.connect() try: return client.call("core.remove_torrent", torrent_hash.lower(), False) except: return False register_plugin('client', 'deluge', DelugeClientPlugin())
return False def find_torrent(self, torrent_hash): client = self.check_connection() if not client: return False try: torrent = client.get_torrent(torrent_hash.lower(), ['id', 'hashString', 'addedDate', 'name']) return { "name": torrent.name, "date_added": torrent.date_added } except KeyError: return False def add_torrent(self, torrent): client = self.check_connection() if not client: return False client.add_torrent(base64.encodestring(torrent)) return True def remove_torrent(self, torrent_hash): client = self.check_connection() if not client: return False client.remove_torrent(torrent_hash, delete_data=False) return True register_plugin('client', 'transmission', TransmissionClientPlugin())
return False def find_torrent(self, torrent_hash): client = self.check_connection() if not client: return False try: torrent = client.get_torrent( torrent_hash.lower(), ['id', 'hashString', 'addedDate', 'name']) return {"name": torrent.name, "date_added": torrent.date_added} except KeyError: return False def add_torrent(self, torrent): client = self.check_connection() if not client: return False client.add_torrent(base64.encodestring(torrent)) return True def remove_torrent(self, torrent_hash): client = self.check_connection() if not client: return False client.remove_torrent(torrent_hash, delete_data=False) return True register_plugin('client', 'transmission', TransmissionClientPlugin())
with DBSession() as db: db.add(topic) topic.hash = torrent.info_hash topic.last_update = last_update db.commit() else: engine.log.info(u"Torrent <b>%s</b> not changed" % topic_name) except Exception as e: engine.log.failed(u"Failed update <b>%s</b>.\nReason: %s" % (topic_name, e.message)) engine.log.info(u"Finish checking for <b>rutor.org</b>") @staticmethod def _get_torrent_info(topic): return { "id": topic.id, "name": topic.display_name, "url": topic.url, "info": None, "last_update": topic.last_update.isoformat() if topic.last_update else None } register_plugin('tracker', PLUGIN_NAME, RutorOrgPlugin(), upgrade=upgrade)
else: engine.log.failed(u"Can't remove old torrent <b>%s</b>" % old_existing_torrent['name']) existing_torrent = engine.find_torrent(torrent.info_hash) if existing_torrent: last_update = existing_torrent['date_added'] else: last_update = datetime.datetime.now() with DBSession() as db: db.add(topic) topic.hash = torrent.info_hash topic.last_update = last_update db.commit() else: engine.log.info(u"Torrent <b>%s</b> not changed" % topic_name) except Exception as e: engine.log.failed(u"Failed update <b>%s</b>.\nReason: %s" % (topic_name, e.message)) engine.log.info(u"Finish checking for <b>rutor.org</b>") @staticmethod def _get_torrent_info(topic): return { "id": topic.id, "name": topic.display_name, "url": topic.url, "info": None, "last_update": topic.last_update.isoformat() if topic.last_update else None } register_plugin('tracker', PLUGIN_NAME, RutorOrgPlugin(), upgrade=upgrade)