Skip to content

Commit

Permalink
Fixes newpct page change.
Browse files Browse the repository at this point in the history
  • Loading branch information
skasi7 committed Sep 21, 2013
1 parent 8641eb0 commit f051b6f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions flexget/plugins/urlrewrite_newpct.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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'])

0 comments on commit f051b6f

Please sign in to comment.