From a5afb9a7259e8214f1702eecbe30ee8a99a840d8 Mon Sep 17 00:00:00 2001 From: back-to Date: Wed, 23 Dec 2020 14:05:44 +0100 Subject: [PATCH] Removed compat.py and constants.py --- liveproxy/argparser.py | 2 +- liveproxy/compat.py | 60 ------------------------------------------ liveproxy/constants.py | 48 --------------------------------- liveproxy/main.py | 1 - liveproxy/server.py | 13 +++------ 5 files changed, 5 insertions(+), 119 deletions(-) delete mode 100644 liveproxy/compat.py delete mode 100644 liveproxy/constants.py diff --git a/liveproxy/argparser.py b/liveproxy/argparser.py index 5cd975e..776b450 100644 --- a/liveproxy/argparser.py +++ b/liveproxy/argparser.py @@ -9,7 +9,6 @@ ) from liveproxy import __version__ as liveproxy_version -from liveproxy.constants import FILE_OUTPUT_LIST _ip_address_re = re.compile(r'^((\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])$') @@ -20,6 +19,7 @@ def ip_address(value): raise ValueError return match.group(0) +FILE_OUTPUT_LIST = ['.m3u', '.m3u8', '.new', '.txt'] def file_output_list(value): diff --git a/liveproxy/compat.py b/liveproxy/compat.py deleted file mode 100644 index 350d193..0000000 --- a/liveproxy/compat.py +++ /dev/null @@ -1,60 +0,0 @@ -import os -import sys - -is_py2 = (sys.version_info[0] == 2) -is_py3 = (sys.version_info[0] == 3) -is_win32 = os.name == "nt" - -try: - from http.server import BaseHTTPRequestHandler - from http.server import HTTPServer -except ImportError: - # Python 2.7 - from BaseHTTPServer import BaseHTTPRequestHandler - from BaseHTTPServer import HTTPServer - -try: - from socketserver import ThreadingMixIn -except ImportError: - # Python 2.7 - from SocketServer import ThreadingMixIn - -try: - from urllib.parse import ( - urlparse, urlunparse, urljoin, quote, unquote, unquote_plus, parse_qsl, urlencode, urlsplit, urlunsplit - ) - import queue -except ImportError: - from urlparse import urlparse, urlunparse, urljoin, parse_qsl, urlsplit, urlunsplit - from urllib import quote, unquote, unquote_plus, urlencode - import Queue as queue - -try: - from shutil import which -except ImportError: - from backports.shutil_which import which - -try: - from html import unescape as html_unescape -except ImportError: - from HTMLParser import HTMLParser - html_unescape = unescape = HTMLParser().unescape - -__all__ = ( - 'BaseHTTPRequestHandler', - 'HTTPServer', - 'ThreadingMixIn', - 'html_unescape', - 'parse_qsl', - 'queue', - 'quote', - 'unquote', - 'unquote_plus', - 'urlencode', - 'urljoin', - 'urlparse', - 'urlsplit', - 'urlunparse', - 'urlunsplit', - 'which', -) diff --git a/liveproxy/constants.py b/liveproxy/constants.py deleted file mode 100644 index fe6b78c..0000000 --- a/liveproxy/constants.py +++ /dev/null @@ -1,48 +0,0 @@ -import os - -from liveproxy.compat import is_py2, is_win32 - -if is_win32: - APPDATA = os.environ['APPDATA'] - CONFIG_FILES = [os.path.join(APPDATA, 'streamlink', 'streamlinkrc')] - PLUGINS_DIR = [os.path.join(APPDATA, 'streamlink', 'plugins')] -else: - XDG_CONFIG_HOME = os.environ.get('XDG_CONFIG_HOME', '~/.config') - CONFIG_FILES = [ - os.path.expanduser(XDG_CONFIG_HOME + '/streamlink/config'), - os.path.expanduser('~/.streamlinkrc') - ] - PLUGINS_DIR = [os.path.expanduser(XDG_CONFIG_HOME + '/streamlink/plugins')] - -STREAM_SYNONYMS = ['best', 'worst', 'best-unfiltered', 'worst-unfiltered'] -STREAM_PASSTHROUGH = ['hls', 'http', 'rtmp'] - -try: - # Kodi - service.liveproxy - import xbmc - if is_py2: - CONFIG_FILES.extend([xbmc.translatePath('special://profile/addon_data/service.liveproxy/config').encode('utf-8')]) - PLUGINS_DIR.extend([ - xbmc.translatePath('special://profile/addon_data/service.liveproxy/plugins/').encode('utf-8'), - xbmc.translatePath('special://home/addons/script.module.back-to-plugins/lib/data/').encode('utf-8'), - xbmc.translatePath('special://home/addons/script.module.streamlink-plugins/lib/data/').encode('utf-8'), - ]) - else: - CONFIG_FILES.extend([xbmc.translatePath('special://profile/addon_data/service.liveproxy/config')]) - PLUGINS_DIR.extend([ - xbmc.translatePath('special://profile/addon_data/service.liveproxy/plugins/'), - xbmc.translatePath('special://home/addons/script.module.back-to-plugins/lib/data/'), - xbmc.translatePath('special://home/addons/script.module.streamlink-plugins/lib/data/'), - ]) -except ImportError: - pass - -FILE_OUTPUT_LIST = ['.m3u', '.m3u8', '.new', '.txt'] - -__all__ = [ - 'CONFIG_FILES', - 'PLUGINS_DIR', - 'STREAM_PASSTHROUGH', - 'STREAM_SYNONYMS', - 'FILE_OUTPUT_LIST', -] diff --git a/liveproxy/main.py b/liveproxy/main.py index a7cf0be..845daf8 100644 --- a/liveproxy/main.py +++ b/liveproxy/main.py @@ -14,7 +14,6 @@ from liveproxy import __version__ as liveproxy_version from liveproxy.argparser import parser -from liveproxy.constants import FILE_OUTPUT_LIST from liveproxy.server import ( HTTPRequest, ThreadedHTTPServer, diff --git a/liveproxy/server.py b/liveproxy/server.py index 07622d0..0ee3247 100644 --- a/liveproxy/server.py +++ b/liveproxy/server.py @@ -24,11 +24,9 @@ from streamlink.stream.ffmpegmux import MuxedStream from streamlink_cli.argparser import build_parser -from liveproxy.compat import ( - BaseHTTPRequestHandler, HTTPServer, ThreadingMixIn, - is_py2, parse_qsl, unquote, urlparse -) -from liveproxy.constants import CONFIG_FILES, PLUGINS_DIR, STREAM_SYNONYMS +from http.server import BaseHTTPRequestHandler, HTTPServer +from socketserver import ThreadingMixIn +from urllib.parse import parse_qsl, unquote, urlparse ACCEPTABLE_ERRNO = ( errno.ECONNABORTED, @@ -576,7 +574,4 @@ class ThreadedHTTPServer(ThreadingMixIn, Server): daemon_threads = True -__all__ = [ - 'HTTPRequest', - 'ThreadedHTTPServer', -] +__all__ = ('HTTPRequest', 'ThreadedHTTPServer')