|
|
@ -255,26 +255,39 @@ def get_first_film(soup, section, year=None, session=None):
|
|
|
|
url = SITE_DOMAIN + t.div.a.get("href")
|
|
|
|
url = SITE_DOMAIN + t.div.a.get("href")
|
|
|
|
break
|
|
|
|
break
|
|
|
|
if not url:
|
|
|
|
if not url:
|
|
|
|
return
|
|
|
|
# fallback to non-year results
|
|
|
|
|
|
|
|
logger.info("Falling back to non-year results as year wasn't found (%s)", year)
|
|
|
|
|
|
|
|
url = SITE_DOMAIN + tag.findNext("ul").find("li").div.a.get("href")
|
|
|
|
|
|
|
|
|
|
|
|
return Film.from_url(url, session=session)
|
|
|
|
return Film.from_url(url, session=session)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def find_endpoint(session, content=None):
|
|
|
|
|
|
|
|
endpoint = region.get("subscene_endpoint2")
|
|
|
|
|
|
|
|
if endpoint is NO_VALUE:
|
|
|
|
|
|
|
|
if not content:
|
|
|
|
|
|
|
|
content = session.get(SITE_DOMAIN).text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m = ENDPOINT_RE.search(content)
|
|
|
|
|
|
|
|
if m:
|
|
|
|
|
|
|
|
endpoint = m.group(1).strip()
|
|
|
|
|
|
|
|
logger.debug("Switching main endpoint to %s", endpoint)
|
|
|
|
|
|
|
|
region.set("subscene_endpoint2", endpoint)
|
|
|
|
|
|
|
|
return endpoint
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def search(term, release=True, session=None, year=None, limit_to=SearchTypes.Exact, throttle=0):
|
|
|
|
def search(term, release=True, session=None, year=None, limit_to=SearchTypes.Exact, throttle=0):
|
|
|
|
# note to subscene: if you actually start to randomize the endpoint, we'll have to query your server even more
|
|
|
|
# note to subscene: if you actually start to randomize the endpoint, we'll have to query your server even more
|
|
|
|
|
|
|
|
|
|
|
|
if release:
|
|
|
|
if release:
|
|
|
|
endpoint = "release"
|
|
|
|
endpoint = "release"
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
endpoint = region.get("subscene_endpoint2")
|
|
|
|
endpoint = find_endpoint(session)
|
|
|
|
if endpoint is NO_VALUE:
|
|
|
|
|
|
|
|
ret = session.get(SITE_DOMAIN)
|
|
|
|
|
|
|
|
time.sleep(throttle)
|
|
|
|
time.sleep(throttle)
|
|
|
|
m = ENDPOINT_RE.search(ret.text)
|
|
|
|
|
|
|
|
if m:
|
|
|
|
if not endpoint:
|
|
|
|
endpoint = m.group(1).strip()
|
|
|
|
logger.error("Couldn't find endpoint, exiting")
|
|
|
|
logger.debug("Switching main endpoint to %s", endpoint)
|
|
|
|
return
|
|
|
|
region.set("subscene_endpoint2", endpoint)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
soup = soup_for("%s/subtitles/%s" % (SITE_DOMAIN, endpoint), data={"query": term},
|
|
|
|
soup = soup_for("%s/subtitles/%s" % (SITE_DOMAIN, endpoint), data={"query": term},
|
|
|
|
session=session)
|
|
|
|
session=session)
|
|
|
|