Add user-agent to newznab providers. closes #211

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