Add user-agent to newznab providers. closes #211
This commit is contained in:
@@ -3,13 +3,14 @@ from couchpotato.core.event import addEvent
|
||||
from couchpotato.core.helpers.request import jsonified
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.plugins.base import Plugin
|
||||
from couchpotato.environment import Env
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Notification(Plugin):
|
||||
|
||||
default_title = 'CouchPotato'
|
||||
default_title = Env.get('appname')
|
||||
test_message = 'ZOMG Lazors Pewpewpew!'
|
||||
|
||||
listen_to = ['movie.downloaded', 'movie.snatched', 'updater.available']
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from couchpotato.core.event import fireEvent
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.notifications.base import Notification
|
||||
from couchpotato.environment import Env
|
||||
from gntp import notifier
|
||||
import logging
|
||||
import traceback
|
||||
@@ -29,7 +30,7 @@ class Growl(Notification):
|
||||
port = self.conf('port')
|
||||
|
||||
self.growl = notifier.GrowlNotifier(
|
||||
applicationName = 'CouchPotato',
|
||||
applicationName = Env.get('appname'),
|
||||
notifications = ["Updates"],
|
||||
defaultNotifications = ["Updates"],
|
||||
applicationIcon = '%s/static/images/couch.png' % fireEvent('app.api_url', single = True),
|
||||
|
||||
@@ -4,6 +4,7 @@ from couchpotato.core.helpers.rss import RSS
|
||||
from couchpotato.core.helpers.variable import cleanHost
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.providers.nzb.base import NZBProvider
|
||||
from couchpotato.environment import Env
|
||||
from dateutil.parser import parse
|
||||
import time
|
||||
import xml.etree.ElementTree as XMLTree
|
||||
@@ -99,7 +100,7 @@ class Newznab(NZBProvider, RSS):
|
||||
def createItems(self, url, cache_key, host, single_cat = False, movie = None, quality = None, for_feed = False):
|
||||
results = []
|
||||
|
||||
data = self.getCache(cache_key, url)
|
||||
data = self.getCache(cache_key, url, cache_timeout = 1800, headers = {'User-Agent': Env.getIdentifier()})
|
||||
if data:
|
||||
try:
|
||||
try:
|
||||
|
||||
@@ -51,7 +51,7 @@ class NZBMatrix(NZBProvider, RSS):
|
||||
cache_key = 'nzbmatrix.%s.%s' % (movie['library'].get('identifier'), cat_ids)
|
||||
single_cat = True
|
||||
|
||||
data = self.getCache(cache_key, url, cache_timeout = 1800, headers = {'User-Agent': 'CouchPotato'})
|
||||
data = self.getCache(cache_key, url, cache_timeout = 1800, headers = {'User-Agent': Env.getIdentifier()})
|
||||
if data:
|
||||
try:
|
||||
try:
|
||||
|
||||
@@ -5,6 +5,8 @@ import os
|
||||
|
||||
class Env(object):
|
||||
|
||||
_appname = 'CouchPotato'
|
||||
|
||||
''' Environment variables '''
|
||||
_encoding = ''
|
||||
_uses_git = False
|
||||
@@ -96,3 +98,7 @@ class Env(object):
|
||||
return '%d %s' % (os.getpid(), '(%d)' % parent if parent and parent > 1 else '')
|
||||
except:
|
||||
return 0
|
||||
|
||||
@staticmethod
|
||||
def getIdentifier():
|
||||
return '%s %s' % (Env.get('appname'), fireEvent('app.version', single = True))
|
||||
|
||||
Reference in New Issue
Block a user