mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-29 06:51:12 -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)
|
searchurl = "https://www.google.com/search?&q={0} site:imdb.com/title/".format(query)
|
||||||
ua = UserAgent()
|
ua = UserAgent()
|
||||||
header = {'User-Agent':str(ua.random)}
|
header = {'User-Agent':str(ua.random)}
|
||||||
data = requests.get(searchurl, headers=header)
|
data = requests.get(searchurl, headers=header, timeout=10)
|
||||||
soup = BeautifulSoup(data.text)
|
soup = BeautifulSoup(data.text)
|
||||||
elements = soup.select('.r a')
|
elements = soup.select('.r a')
|
||||||
url = urljoin(elements[0]['href'], urlparse(url).path)
|
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)
|
searchurl = "https://www.google.com/search?&q={0} site:lyrics.fandom.com/wiki/".format(lyric)
|
||||||
ua = UserAgent()
|
ua = UserAgent()
|
||||||
header = {'User-Agent':str(ua.random)}
|
header = {'User-Agent':str(ua.random)}
|
||||||
data = requests.get(searchurl, headers=header)
|
data = requests.get(searchurl, headers=header, timeout=10)
|
||||||
soup = BeautifulSoup(data.text)
|
soup = BeautifulSoup(data.text)
|
||||||
elements = soup.select('.r a')
|
elements = soup.select('.r a')
|
||||||
title = soup.find("h3").getText().replace(":", " - ").split('|')[0]
|
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)
|
searchurl = "https://www.google.com/search?&q={0} site:youtube.com".format(query)
|
||||||
ua = UserAgent()
|
ua = UserAgent()
|
||||||
header = {'User-Agent':str(ua.random)}
|
header = {'User-Agent':str(ua.random)}
|
||||||
data = requests.get(searchurl, headers=header)
|
data = requests.get(searchurl, headers=header, timeout=10)
|
||||||
soup = BeautifulSoup(data.text)
|
soup = BeautifulSoup(data.text)
|
||||||
elements = soup.select('.r a')
|
elements = soup.select('.r a')
|
||||||
for i in range(len(elements)):
|
for i in range(len(elements)):
|
||||||
@ -188,7 +188,7 @@ class YouTube(callbacks.Plugin):
|
|||||||
|
|
||||||
log.debug("YouTube: requesting %s" % (api_url))
|
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
|
ok = request.status_code == requests.codes.ok
|
||||||
|
|
||||||
if 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