mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-25 20:41:21 -05:00
YouTube/IMDb/SpiffyTitles: add timeouts
This commit is contained in:
parent
a8d7435c53
commit
6655671ef1
@ -60,7 +60,7 @@ class IMDb(callbacks.Plugin):
|
||||
searchurl = "https://www.google.com/search?&q={0} site:imdb.com/title/".format(query)
|
||||
ua = UserAgent()
|
||||
header = {'User-Agent':str(ua.random)}
|
||||
data = requests.get(searchurl, headers=header)
|
||||
data = requests.get(searchurl, headers=header, timeout=10)
|
||||
soup = BeautifulSoup(data.text)
|
||||
elements = soup.select('.r a')
|
||||
url = urljoin(elements[0]['href'], urlparse(url).path)
|
||||
|
@ -60,7 +60,7 @@ class Lyrics(callbacks.Plugin):
|
||||
searchurl = "https://www.google.com/search?&q={0} site:lyrics.fandom.com/wiki/".format(lyric)
|
||||
ua = UserAgent()
|
||||
header = {'User-Agent':str(ua.random)}
|
||||
data = requests.get(searchurl, headers=header)
|
||||
data = requests.get(searchurl, headers=header, timeout=10)
|
||||
soup = BeautifulSoup(data.text)
|
||||
elements = soup.select('.r a')
|
||||
title = soup.find("h3").getText().replace(":", " - ").split('|')[0]
|
||||
|
@ -64,7 +64,7 @@ class YouTube(callbacks.Plugin):
|
||||
searchurl = "https://www.google.com/search?&q={0} site:youtube.com".format(query)
|
||||
ua = UserAgent()
|
||||
header = {'User-Agent':str(ua.random)}
|
||||
data = requests.get(searchurl, headers=header)
|
||||
data = requests.get(searchurl, headers=header, timeout=10)
|
||||
soup = BeautifulSoup(data.text)
|
||||
elements = soup.select('.r a')
|
||||
for i in range(len(elements)):
|
||||
@ -188,7 +188,7 @@ class YouTube(callbacks.Plugin):
|
||||
|
||||
log.debug("YouTube: requesting %s" % (api_url))
|
||||
|
||||
request = requests.get(api_url)
|
||||
request = requests.get(api_url, timeout=10)
|
||||
ok = request.status_code == requests.codes.ok
|
||||
|
||||
if ok:
|
||||
|
5
YouTube/requirements.txt
Normal file
5
YouTube/requirements.txt
Normal file
@ -0,0 +1,5 @@
|
||||
requests
|
||||
pendulum
|
||||
beautifulsoup4
|
||||
fake_useragent
|
||||
jinja2
|
Loading…
x
Reference in New Issue
Block a user