Merge pull request #2631 from mano3m/develop_try_next

Download fixed
This commit is contained in:
Ruud Burger committed 2013-12-27 11:18:07 -08:00
commit 4a36c3b6a8
2 files changed
+6 -4

No files matched your search

+5 -4
View File
@@ -241,13 +241,13 @@ class Release(Plugin):
'files': {} 'files': {}
}), manual = True) }), manual = True)
if success: if success == True:
db.expunge_all() db.expunge_all()
rel = db.query(Relea).filter_by(id = id).first() # Get release again @RuudBurger why do we need to get it again?? rel = db.query(Relea).filter_by(id = id).first() # Get release again @RuudBurger why do we need to get it again??
fireEvent('notify.frontend', type = 'release.manual_download', data = True, message = 'Successfully snatched "%s"' % item['name']) fireEvent('notify.frontend', type = 'release.manual_download', data = True, message = 'Successfully snatched "%s"' % item['name'])
return { return {
'success': success 'success': success == True
} }
def download(self, data, media, manual = False): def download(self, data, media, manual = False):
@@ -260,20 +260,21 @@ class Release(Plugin):
# Test to see if any downloaders are enabled for this type # Test to see if any downloaders are enabled for this type
downloader_enabled = fireEvent('download.enabled', manual, data, single = True) downloader_enabled = fireEvent('download.enabled', manual, data, single = True)
if not downloader_enabled: if not downloader_enabled:
log.info('Tried to download, but none of the "%s" downloaders are enabled or gave an error', (data.get('protocol'))) log.info('Tried to download, but none of the "%s" downloaders are enabled or gave an error', data.get('protocol'))
return False return False
# Download NZB or torrent file # Download NZB or torrent file
filedata = None filedata = None
if data.get('download') and (ismethod(data.get('download')) or isfunction(data.get('download'))): if data.get('download') and (ismethod(data.get('download')) or isfunction(data.get('download'))):
filedata = data.get('download')(url = data.get('url'), nzb_id = data.get('id')) filedata = data.get('download')(url = data.get('url'), nzb_id = data.get('id'))
log.info('Tried to download, but the "%s" provider gave an error', data.get('protocol'))
if filedata == 'try_next': if filedata == 'try_next':
return filedata return filedata
# Send NZB or torrent file to downloader # Send NZB or torrent file to downloader
download_result = fireEvent('download', data = data, media = media, manual = manual, filedata = filedata, single = True) download_result = fireEvent('download', data = data, media = media, manual = manual, filedata = filedata, single = True)
if not download_result: if not download_result:
log.info('Tried to download, but the "%s" downloader gave an error', (data.get('protocol'))) log.info('Tried to download, but the "%s" downloader gave an error', data.get('protocol'))
return False return False
log.debug('Downloader result: %s', download_result) log.debug('Downloader result: %s', download_result)
@@ -163,6 +163,7 @@ class Newznab(NZBProvider, RSS):
# Get final redirected url # Get final redirected url
log.debug('Checking %s for redirects.', url) log.debug('Checking %s for redirects.', url)
req = urllib2.Request(url) req = urllib2.Request(url)
req.add_header('User-Agent', self.user_agent)
res = urllib2.urlopen(req) res = urllib2.urlopen(req)
finalurl = res.geturl() finalurl = res.geturl()
if finalurl != url: if finalurl != url: