本文整理汇总了Python中sickbeard.helpers.getURL函数的典型用法代码示例。如果您正苦于以下问题:Python getURL函数的具体用法?Python getURL怎么用?Python getURL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getURL函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getDBcompare
def getDBcompare(self):
"""
Compare the current DB version with the new branch version.
:return: 'upgrade', 'equal', or 'downgrade'
"""
try:
self.updater.need_update()
cur_hash = str(self.updater.get_newest_commit_hash())
assert len(cur_hash) == 40, 'Commit hash wrong length: {length} hash: {hash}'.format(
length=len(cur_hash), hash=cur_hash)
check_url = 'http://cdn.rawgit.com/{org}/{repo}/{commit}/sickbeard/databases/main_db.py'.format(
org=sickbeard.GIT_ORG, repo=sickbeard.GIT_REPO, commit=cur_hash)
response = helpers.getURL(check_url, session=self.session)
if response.status_code == 404:
check_url.replace('main_db.py', 'mainDB.py')
response = helpers.getURL(check_url, session=self.session)
match = re.search(r'MAX_DB_VERSION\s=\s(?P<version>\d{2,3})', response.text)
new_branch_db_version = int(match.group('version'))
main_db_con = db.DBConnection()
cur_branch_db_version = main_db_con.checkDBVersion()
if new_branch_db_version > cur_branch_db_version:
return 'upgrade'
elif new_branch_db_version == cur_branch_db_version:
return 'equal'
else:
return 'downgrade'
except Exception as e:
return repr(e)
开发者ID:bitzorro,项目名称:SickRage,代码行数:32,代码来源:versionChecker.py
示例2: get_url
def get_url(self, url, post_data=None, params=None, timeout=30, json=False, need_bytes=False): # pylint: disable=too-many-arguments
"""
need_bytes=True when trying access to torrent info (For calling torrent client). Previously we must parse
the URL to get torrent file
"""
if need_bytes:
data = helpers.getURL(url, headers=self.headers, timeout=timeout, session=self.session, returns='json')
url = re.search(r'http://tumejorserie.com/descargar/.+\.torrent', data, re.DOTALL).group()
return helpers.getURL(url, post_data=post_data, params=params, headers=self.headers, timeout=timeout,
session=self.session, json=json, need_bytes=need_bytes)
开发者ID:piejanssens,项目名称:SickRage-1,代码行数:11,代码来源:newpct.py
示例3: sendNZB
def sendNZB(nzb): # pylint:disable=too-many-return-statements, too-many-branches, too-many-statements
'''
Sends an NZB to SABnzbd via the API.
:param nzb: The NZBSearchResult object to send to SAB
'''
category = sickbeard.SAB_CATEGORY
if nzb.show.is_anime:
category = sickbeard.SAB_CATEGORY_ANIME
# if it aired more than 7 days ago, override with the backlog category IDs
for curEp in nzb.episodes:
if datetime.date.today() - curEp.airdate > datetime.timedelta(days=7):
category = sickbeard.SAB_CATEGORY_ANIME_BACKLOG if nzb.show.is_anime else sickbeard.SAB_CATEGORY_BACKLOG
# set up a dict with the URL params in it
params = {'output': 'json'}
if sickbeard.SAB_USERNAME is not None:
params['ma_username'] = sickbeard.SAB_USERNAME
if sickbeard.SAB_PASSWORD is not None:
params['ma_password'] = sickbeard.SAB_PASSWORD
if sickbeard.SAB_APIKEY is not None:
params['apikey'] = sickbeard.SAB_APIKEY
if category is not None:
params['cat'] = category
if nzb.priority:
params['priority'] = 2 if sickbeard.SAB_FORCED else 1
if nzb.resultType == 'nzb':
params['mode'] = 'addurl'
params['name'] = nzb.url
elif nzb.resultType == 'nzbdata':
params['mode'] = 'addfile'
multiPartParams = {'nzbfile': (nzb.name + '.nzb', nzb.extraInfo[0])}
logger.log('Sending NZB to SABnzbd')
url = urljoin(sickbeard.SAB_HOST, 'api')
if nzb.resultType == 'nzb':
jdata = helpers.getURL(url, params=params, session=session, returns='json', headers={'User-Agent': USER_AGENT})
elif nzb.resultType == 'nzbdata':
jdata = helpers.getURL(url, file=multiPartParams, session=session, returns='json', headers={'User-Agent': USER_AGENT})
if not jdata:
logger.log('Error connecting to sab, no data returned')
return False
logger.log('Result text from SAB: {0}'.format(jdata), logger.DEBUG)
result, _ = _checkSabResponse(jdata)
return result
开发者ID:ratoaq2,项目名称:SickRageSickRage,代码行数:54,代码来源:sab.py
示例4: sendNZB
def sendNZB(nzb): # pylint:disable=too-many-return-statements, too-many-branches, too-many-statements
"""
Sends an NZB to SABnzbd via the API.
:param nzb: The NZBSearchResult object to send to SAB
"""
category = sickbeard.SAB_CATEGORY
if nzb.show.is_anime:
category = sickbeard.SAB_CATEGORY_ANIME
# if it aired more than 7 days ago, override with the backlog category IDs
for curEp in nzb.episodes:
if datetime.date.today() - curEp.airdate > datetime.timedelta(days=7):
category = sickbeard.SAB_CATEGORY_ANIME_BACKLOG if nzb.show.is_anime else sickbeard.SAB_CATEGORY_BACKLOG
# set up a dict with the URL params in it
params = {"output": "json"}
if sickbeard.SAB_USERNAME:
params["ma_username"] = sickbeard.SAB_USERNAME
if sickbeard.SAB_PASSWORD:
params["ma_password"] = sickbeard.SAB_PASSWORD
if sickbeard.SAB_APIKEY:
params["apikey"] = sickbeard.SAB_APIKEY
if category:
params["cat"] = category
if nzb.priority:
params["priority"] = 2 if sickbeard.SAB_FORCED else 1
logger.log("Sending NZB to SABnzbd")
url = urljoin(sickbeard.SAB_HOST, "api")
if nzb.resultType == "nzb":
params["mode"] = "addurl"
params["name"] = nzb.url
jdata = helpers.getURL(url, params=params, session=session, returns="json", verify=False)
elif nzb.resultType == "nzbdata":
params["mode"] = "addfile"
multiPartParams = {"nzbfile": (nzb.name + ".nzb", nzb.extraInfo[0])}
jdata = helpers.getURL(url, params=params, file=multiPartParams, session=session, returns="json", verify=False)
if not jdata:
logger.log("Error connecting to sab, no data returned")
return False
logger.log("Result text from SAB: {0}".format(jdata), logger.DEBUG)
result, error_ = _checkSabResponse(jdata)
return result
开发者ID:Arcanemagus,项目名称:SickRage,代码行数:51,代码来源:sab.py
示例5: _do_login
def _do_login(self):
logged_in = lambda: 'gft_uid' in self.session.cookies and 'gft_pass' in self.session.cookies
if logged_in():
return True
if self._check_auth():
helpers.getURL(self.urls['login_get'], session=self.session)
login_params = {'username': self.username, 'password': self.password}
response = helpers.getURL(self.urls['login_post'], post_data=login_params, session=self.session)
if response and logged_in():
return True
logger.log(u'Failed to authenticate with %s, abort provider.' % self.name, logger.ERROR)
return False
开发者ID:joshguerette,项目名称:SickGear,代码行数:16,代码来源:gftracker.py
示例6: _getTVRageInfo
def _getTVRageInfo(self, season=None, episode=None, full=False):
url = "http://services.tvrage.com/tools/quickinfo.php?"
# if we need full info OR if we don't have a tvrage id, use show name
if full == True or self.show.tvrid == 0:
if self.show.tvrname != "" and self.show.tvrname != None:
showName = self.show.tvrname
else:
showName = self.show.name
urlData = {'show': showName.encode('utf-8')}
# if we don't need full info and we have a tvrage id, use it
else:
urlData = {'sid': self.show.tvrid}
if season != None and episode != None:
urlData['ep'] = str(season)+'x'+str(episode)
# build the URL
url += urllib.urlencode(urlData)
logger.log(u"Loading TVRage info from URL: " + url, logger.DEBUG)
try:
result = helpers.getURL(url).decode('utf-8')
except (urllib2.HTTPError, IOError), e:
logger.log(u"Unable to load TVRage info: " + e.message.decode(sickbeard.SYS_ENCODING))
raise exceptions.TVRageException("urlopen call to " + url + " failed")
开发者ID:abush,项目名称:Sick-Beard,代码行数:30,代码来源:tvrage.py
示例7: _sabURLOpenSimple
def _sabURLOpenSimple(url):
try:
result = helpers.getURL(url, throw_exc=True)
f = StringIO.StringIO(result)
except (EOFError, IOError), e:
logger.log(u"Unable to connect to SAB: " + ex(e), logger.ERROR)
return False, "Unable to connect"
开发者ID:vultuk,项目名称:Sick-Beard,代码行数:7,代码来源:sab.py
示例8: _xem_exceptions_fetcher
def _xem_exceptions_fetcher():
if shouldRefresh('xem'):
for indexer in sickbeard.indexerApi().indexers:
logger.log(u'Checking for XEM scene exception updates for {0}'.format
(sickbeard.indexerApi(indexer).name))
url = 'http://thexem.de/map/allNames?origin={0}&seasonNumbers=1'.format(sickbeard.indexerApi(indexer).config['xem_origin'])
parsedJSON = helpers.getURL(url, session=xem_session, timeout=90, returns='json')
if not parsedJSON:
logger.log(u'Check scene exceptions update failed for {0}, Unable to get URL: {1}'.format
(sickbeard.indexerApi(indexer).name, url), logger.DEBUG)
continue
if parsedJSON['result'] == 'failure':
continue
if not parsedJSON['data']:
logger.log(u'No data returned from XEM when checking scene exceptions. Update failed for {0}'.format
(sickbeard.indexerApi(indexer).name), logger.DEBUG)
continue
for indexerid, names in iteritems(parsedJSON['data']):
try:
xem_exception_dict[int(indexerid)] = names
except Exception as error:
logger.log(u'XEM: Rejected entry: indexerid:{0}; names:{1}'.format(indexerid, names), logger.WARNING)
logger.log(u'XEM: Rejected entry error message:{0}'.format(error), logger.DEBUG)
setLastRefresh('xem')
return xem_exception_dict
开发者ID:Thraxis,项目名称:pymedusa,代码行数:32,代码来源:scene_exceptions.py
示例9: getDBcompare
def getDBcompare(self):
try:
self.updater.need_update()
cur_hash = str(self.updater.get_newest_commit_hash())
assert len(cur_hash) == 40, "Commit hash wrong length: %s hash: %s" % (len(cur_hash), cur_hash)
check_url = "http://cdn.rawgit.com/%s/%s/%s/sickbeard/databases/mainDB.py" % (
sickbeard.GIT_ORG,
sickbeard.GIT_REPO,
cur_hash,
)
response = helpers.getURL(check_url, session=self.session)
assert response, "Empty response from %s" % check_url
match = re.search(r"MAX_DB_VERSION\s=\s(?P<version>\d{2,3})", response)
branchDestDBversion = int(match.group("version"))
main_db_con = db.DBConnection()
branchCurrDBversion = main_db_con.checkDBVersion()
if branchDestDBversion > branchCurrDBversion:
return "upgrade"
elif branchDestDBversion == branchCurrDBversion:
return "equal"
else:
return "downgrade"
except Exception as e:
return repr(e)
开发者ID:lastdevonearth,项目名称:SickRage,代码行数:26,代码来源:versionChecker.py
示例10: getURL
def getURL(self, url, post_data=None, params=None, timeout=30, json=False):
"""
By default this is just a simple urlopen call but this method should be overridden
for providers with special URL requirements (like cookies)
"""
# check for auth
if not self._doLogin():
return
if self.proxy.isEnabled():
self.headers.update({"Referer": self.proxy.getProxyURL()})
self.proxyGlypeProxySSLwarning = (
self.proxy.getProxyURL() + "includes/process.php?action=sslagree&submit=Continue anyway..."
)
else:
if "Referer" in self.headers:
self.headers.pop("Referer")
self.proxyGlypeProxySSLwarning = None
return helpers.getURL(
self.proxy._buildURL(url),
post_data=post_data,
params=params,
headers=self.headers,
timeout=timeout,
session=self.session,
json=json,
proxyGlypeProxySSLwarning=self.proxyGlypeProxySSLwarning,
)
开发者ID:brusilva,项目名称:SickRage,代码行数:30,代码来源:generic.py
示例11: _xem_exceptions_fetcher
def _xem_exceptions_fetcher():
global xem_exception_dict
xem_list = 'xem_us'
for show in sickbeard.showList:
if show.is_anime and not show.paused:
xem_list = 'xem'
break
if shouldRefresh(xem_list):
for indexer in [i for i in sickbeard.indexerApi().indexers if 'xem_origin' in sickbeard.indexerApi(i).config]:
logger.log(u'Checking for XEM scene exception updates for %s' % sickbeard.indexerApi(indexer).name)
url = 'http://thexem.de/map/allNames?origin=%s%s&seasonNumbers=1'\
% (sickbeard.indexerApi(indexer).config['xem_origin'], ('&language=us', '')['xem' == xem_list])
parsed_json = helpers.getURL(url, json=True, timeout=90)
if not parsed_json:
logger.log(u'Check scene exceptions update failed for %s, Unable to get URL: %s'
% (sickbeard.indexerApi(indexer).name, url), logger.ERROR)
continue
if 'failure' == parsed_json['result']:
continue
for indexerid, names in parsed_json['data'].items():
try:
xem_exception_dict[int(indexerid)] = names
except:
continue
setLastRefresh(xem_list)
return xem_exception_dict
开发者ID:JackDandy,项目名称:SickGear,代码行数:34,代码来源:scene_exceptions.py
示例12: check_for_new_news
def check_for_new_news(self, force=False):
"""
Checks GitHub for the latest news.
returns: str, a copy of the news
force: if true the VERSION_NOTIFY setting will be ignored and a check will be forced
"""
if not self.updater or not sickbeard.VERSION_NOTIFY and not sickbeard.AUTO_UPDATE and not force:
logger.log(u"check_for_new_news: Version checking is disabled, not checking for latest news")
return ''
# Grab a copy of the news
logger.log(u'check_for_new_news: Checking GitHub for latest news.', logger.DEBUG)
try:
news = helpers.getURL(sickbeard.NEWS_URL, session=requests.Session())
except Exception:
logger.log(u'check_for_new_news: Could not load news from repo.', logger.WARNING)
last_read = time.mktime(time.strptime(sickbeard.NEWS_LAST_READ, '%Y-%m-%d'))
dates= re.finditer(r'^####(\d{4}-\d{2}-\d{2})####$', news, re.M)
sickbeard.NEWS_UNREAD = 0
gotLatest = False
for match in dates:
if not gotLatest:
gotLatest = True
sickbeard.NEWS_LATEST = match.group(1)
if time.mktime(time.strptime(match.group(1), '%Y-%m-%d')) > last_read:
sickbeard.NEWS_UNREAD += 1
return news
开发者ID:adrianmoisey,项目名称:SickRage,代码行数:34,代码来源:versionChecker.py
示例13: testAuthentication
def testAuthentication(host=None, username=None, password=None, apikey=None):
"""
Sends a simple API request to SAB to determine if the given connection information is connect
:param host: The host where SAB is running (incl port)
:param username: The username to use for the HTTP request
:param password: The password to use for the HTTP request
:param apikey: The API key to provide to SAB
:return: A tuple containing the success boolean and a message
"""
# build up the URL parameters
params = {"mode": "queue", "output": "json", "ma_username": username, "ma_password": password, "apikey": apikey}
url = urljoin(host, "api")
data = helpers.getURL(url, params=params, session=session, returns="json", verify=False)
if not data:
return False, data
# check the result and determine if it's good or not
result, sabText = _checkSabResponse(data)
if not result:
return False, sabText
return True, "Success"
开发者ID:Arcanemagus,项目名称:SickRage,代码行数:26,代码来源:sab.py
示例14: get_url_x
def get_url_x(self, url, token=None, **kwargs):
if not token:
token = self.token
if not url.startswith('http'):
url = 'http://' + url
for x in range(0, 3):
if 0 < x:
sleep(0.5)
try:
headers = {'X-Plex-Device-Name': 'SickGear',
'X-Plex-Platform': platform.system(), 'X-Plex-Device': platform.system(),
'X-Plex-Platform-Version': platform.release(),
'X-Plex-Provides': 'controller', 'X-Plex-Product': 'Python',
'X-Plex-Client-Identifier': self.client_id,
'X-Plex-Version': str(self.config_version),
'X-Plex-Token': token,
'Accept': 'application/xml'
}
if self.username:
headers.update({'X-Plex-Username': self.username})
page = getURL(url, headers=headers, **kwargs)
if page:
parsed = etree.fromstring(page)
if None is not parsed and len(parsed):
return parsed
return None
except Exception as e:
self.log('Error requesting page: %s' % e)
continue
return None
开发者ID:JackDandy,项目名称:SickGear,代码行数:33,代码来源:plex.py
示例15: get_feed
def get_feed(self, url, request_headers=None):
if not self._check_auth_cookie():
return
session = None
if self.provider and hasattr(self.provider, 'session'):
session = self.provider.session
response = helpers.getURL(url, headers=request_headers, session=session)
if not response:
return
try:
feed = feedparser.parse(response)
if feed and 'entries' in feed:
return feed
if feed and 'error' in feed.feed:
err_code = feed.feed['error']['code']
err_desc = feed.feed['error']['description']
logger.log(u'RSS ERROR:[%s] CODE:[%s]' % (err_desc, err_code), logger.DEBUG)
else:
logger.log(u'RSS error loading url: ' + url, logger.DEBUG)
except Exception as e:
logger.log(u'RSS error: ' + ex(e), logger.DEBUG)
开发者ID:Apocrathia,项目名称:SickGear,代码行数:27,代码来源:rssfeeds.py
示例16: _xem_get_ids
def _xem_get_ids(indexer_name, xem_origin):
xem_ids = []
url = 'http://thexem.de/map/havemap?origin=%s' % xem_origin
task = 'Fetching show ids with%s xem scene mapping%s for origin'
logger.log(u'%s %s' % (task % ('', 's'), indexer_name))
parsed_json = helpers.getURL(url, json=True, timeout=90)
if not parsed_json:
logger.log(u'Failed %s %s, Unable to get URL: %s'
% (task.lower() % ('', 's'), indexer_name, url), logger.ERROR)
else:
if 'result' in parsed_json and 'success' == parsed_json['result'] and 'data' in parsed_json:
try:
for indexerid in parsed_json['data']:
xem_id = helpers.tryInt(indexerid)
if xem_id and xem_id not in xem_ids:
xem_ids.append(xem_id)
except:
pass
if 0 == len(xem_ids):
logger.log(u'Failed %s %s, no data items parsed from URL: %s'
% (task.lower() % ('', 's'), indexer_name, url), logger.WARNING)
logger.log(u'Finished %s %s' % (task.lower() % (' %s' % len(xem_ids), helpers.maybe_plural(len(xem_ids))),
indexer_name))
return xem_ids
开发者ID:JackDandy,项目名称:SickGear,代码行数:27,代码来源:scene_exceptions.py
示例17: _xem_exceptions_fetcher
def _xem_exceptions_fetcher():
exception_dict = {}
if shouldRefresh('xem'):
success = False
for indexer in sickbeard.indexerApi().indexers:
logger.log(u"Checking for XEM scene exception updates for " + sickbeard.indexerApi(indexer).name)
url = "http://thexem.de/map/allNames?origin=%s&seasonNumbers=1" % sickbeard.indexerApi(indexer).config[
'xem_origin']
url_data = helpers.getURL(url, json=True)
if url_data is None:
logger.log(u"Check scene exceptions update failed for " + sickbeard.indexerApi(
indexer).name + ", Unable to get URL: " + url, logger.ERROR)
continue
if url_data['result'] == 'failure':
continue
for indexerid, names in url_data['data'].items():
exception_dict[int(indexerid)] = names
success = True
if success:
setLastRefresh('xem')
return exception_dict
开发者ID:achlee,项目名称:SickRage,代码行数:30,代码来源:scene_exceptions.py
示例18: getShowImage
def getShowImage(url, imgNum=None):
est = eec.set(getShowImage, str(url))
image_data = None
if url == None:
eec.clock(est, False)
return None
# if they provided a fanart number try to use it instead
if imgNum != None:
tempURL = url.split('-')[0] + "-" + str(imgNum) + ".jpg"
else:
tempURL = url
logger.log(u"Getting show image at "+tempURL, logger.DEBUG)
image_data = helpers.getURL(tempURL)
if image_data is None:
logger.log(u"There was an error trying to retrieve the image, aborting", logger.ERROR)
eec.clock(est, False)
return None
eec.clock(est, True)
return image_data
开发者ID:fuzeman,项目名称:Sick-Beard-Ex,代码行数:26,代码来源:helpers.py
示例19: splitResult
def splitResult(result):
try:
urlData = helpers.getURL(result.url)
except urllib2.URLError, e:
logger.log(u"Unable to load url "+result.url+", can't download season NZB", logger.ERROR)
return False
开发者ID:AWilco,项目名称:Sick-Beard,代码行数:7,代码来源:nzbSplitter+(MOU-CDQT5R1's+conflicted+copy+2012-04-11).py
示例20: _get_showrss_id
def _get_showrss_id(cls, tvdb_id):
try:
unusedVar = cls.knownShows
except AttributeError:
cls.knownShows = {}
try:
cachedResult = cls.knownShows[str(tvdb_id)]
if time.time() < (cachedResult['mtime'] + UPDATE_INTERVAL):
# cached result is still considered current, use it
return cachedResult['response']
# otherwise we just fall through to lookup
except KeyError:
pass # no cached value, just fall through to lookup
url = SHOW_LOOKUP_URL + '?tvdb_id=' + str(tvdb_id)
data = helpers.getURL(url)
result = json.loads(data)
if not result:
logger.log(u"Empty lookup result -> failed to find show id", logger.DEBUG)
return None
if result['error']:
logger.log(u"Lookup failed: " + result['errorMessage'], logger.DEBUG)
return None
# result is good, store it for later
cls.knownShows[str(tvdb_id)] = {'mtime': time.time(),
'response': result['show']['showrss_id'] }
return result['show']['showrss_id']
开发者ID:SvenVdB,项目名称:Sick-Beard,代码行数:31,代码来源:showrss.py
注:本文中的sickbeard.helpers.getURL函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论