# -*- coding: utf-8 -*- # vim: fenc=utf-8 ts=4 et sw=4 sts=4 # This file is part of Subscene-API. # # Subscene-API is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # Subscene-API is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ Python wrapper for Subscene subtitle database. since Subscene doesn't provide an official API, I wrote this script that does the job by parsing the website"s pages. """ # imports import re import enum import sys import requests import time import logging is_PY2 = sys.version_info[0] < 3 if is_PY2: from contextlib2 import suppress from urllib2 import Request, urlopen else: from contextlib import suppress from urllib.request import Request, urlopen from dogpile.cache.api import NO_VALUE from subliminal.cache import region from bs4 import BeautifulSoup, NavigableString logger = logging.getLogger(__name__) # constants HEADERS = { } SITE_DOMAIN = "https://subscene.com" DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWeb"\ "Kit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36" ENDPOINT_RE = re.compile(r'(?uis).*?