From f051b6fb620c2290fbffa1273cdc2dca344bd5fe Mon Sep 17 00:00:00 2001 From: skasi7 Date: Sat, 21 Sep 2013 09:54:46 +0200 Subject: [PATCH] Fixes newpct page change. --- flexget/plugins/urlrewrite_newpct.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/flexget/plugins/urlrewrite_newpct.py b/flexget/plugins/urlrewrite_newpct.py index 49a8e527e3..ad054bc104 100644 --- a/flexget/plugins/urlrewrite_newpct.py +++ b/flexget/plugins/urlrewrite_newpct.py @@ -1,7 +1,9 @@ from __future__ import unicode_literals, division, absolute_import -import urllib2 import logging +import os import re +import urllib2 +from urlparse import urlparse from flexget.plugins.plugin_urlrewriting import UrlRewritingError from flexget.plugin import register_plugin, internet @@ -36,10 +38,11 @@ def parse_download_page(self, url): soup = get_soup(page) except Exception, e: raise UrlRewritingError(e) - down_link = soup.find('a', attrs={'href': re.compile("descargar/torrent/")}) - if not down_link: - raise UrlRewritingError('Unable to locate download link from url %s' % url) - return down_link.get('href') - + torrent_id_prog = re.compile("'torrentID': '(\d+)'") + torrent_ids = soup.findAll(text=torrent_id_prog) + if len(torrent_ids) == 0: + raise UrlRewritingError('Unable to locate torret ID from url %s' % url) + torrent_id = torrent_id_prog.search(torrent_ids[0]).group(1) + return 'http://www.pctorrent.com/descargar/index.php?link=descargar/torrent/%s/dummy.html' % torrent_id register_plugin(UrlRewriteNewPCT, 'newpct', groups=['urlrewriter'])