Skip to content

Commit

Permalink
[fix] rmz urlrewriter: fixed bug that loses links if another plugin a…
Browse files Browse the repository at this point in the history
…dds links to the urls field of an entry before the urlrewriter is executed (Flexget#1886)
  • Loading branch information
thawn authored and liiight committed Jun 22, 2017
1 parent b466d7b commit 1723e16
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions flexget/plugins/sites/rmz.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UrlRewriteRmz(object):
- domain\.com
- domain2\.org
Only add links that match any of the regular expressions listed under url_re.
Only add links that match any of the regular expressions listed under filehosters_re.
If more than one valid link is found, the url of the entry is rewritten to
the first link found. The complete list of valid links is placed in the
Expand Down Expand Up @@ -76,7 +76,10 @@ def url_rewrite(self, task, entry):
except Exception as e:
raise UrlRewritingError(str(e))
link_elements = soup.find_all('pre', class_='links')
urls = []
if entry['urls']:
urls = list(entry['urls'])
else:
urls = []
for element in link_elements:
urls.extend(element.text.splitlines())
regexps = self.config.get('filehosters_re', [])
Expand All @@ -89,8 +92,8 @@ def url_rewrite(self, task, entry):
log.debug('Url: "%s" matched filehoster filter: %s', urls[i], regexp)
break
else:
log.debug(
'Url: "%s" does not match any of the given filehoster filters: %s', urls[i], str(regexps))
if regexps:
log.debug('Url: "%s" does not match any of the given filehoster filters: %s', urls[i], str(regexps))
if regexps:
log.debug('Using filehosters_re filters: %s', str(regexps))
urls = filtered_urls
Expand All @@ -99,7 +102,7 @@ def url_rewrite(self, task, entry):
num_links = len(urls)
log.verbose('Found %d links at %s.', num_links, entry['url'])
if num_links:
entry.setdefault('urls', urls)
entry['urls'] = urls
entry['url'] = urls[0]
else:
raise UrlRewritingError('No useable links found at %s' % entry['url'])
Expand Down

0 comments on commit 1723e16

Please sign in to comment.