1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

swap place on py2 and py3 checks

This commit is contained in:
Johan Andersson 2016-01-27 19:49:38 +01:00
parent 219a134069
commit 3f04ae2a56
5 changed files with 27 additions and 25 deletions

View File

@ -9,7 +9,7 @@ import copy
import xml.etree.ElementTree as ET
from svtplay_dl.output import progressbar, progress_stream, ETA, output
from svtplay_dl.utils import is_py2_old, is_py2, is_py3
from svtplay_dl.utils import is_py2_old, is_py2
from svtplay_dl.utils.urllib import urlparse
from svtplay_dl.error import UIException
from svtplay_dl.fetcher import VideoRetriever
@ -25,8 +25,7 @@ if is_py2:
def _chr(temp):
return temp
if is_py3:
else:
def _chr(temp):
return chr(temp)

View File

@ -9,7 +9,7 @@ import io
import platform
from datetime import timedelta
from svtplay_dl.utils import is_py3, is_py2, filenamify, decode_html_entities, ensure_unicode
from svtplay_dl.utils import is_py2, filenamify, decode_html_entities, ensure_unicode
from svtplay_dl.utils.terminal import get_terminal_size
from svtplay_dl.log import log
@ -142,10 +142,10 @@ def filename(stream):
def output(options, extention="mp4", openfd=True, mode="wb", **kwargs):
if is_py3:
file_d = io.IOBase
else:
if is_py2:
file_d = file
else:
file_d = io.IOBase
if options.output != "-":
ext = re.search(r"(\.\w{2,3})$", options.output)
@ -170,10 +170,10 @@ def output(options, extention="mp4", openfd=True, mode="wb", **kwargs):
file_d = open(options.output, mode, **kwargs)
else:
if openfd:
if is_py3:
file_d = sys.stdout.buffer
else:
if is_py2:
file_d = sys.stdout
else:
file_d = sys.stdout.buffer
return file_d

View File

@ -50,10 +50,11 @@ class subtitle(object):
def tt(self, subdata):
i = 1
data = ""
if is_py3:
subs = subdata.text
else:
if is_py2:
subs = subdata.text.encode("utf8")
else:
subs = subdata.text
subdata = re.sub(' xmlns="[^"]+"', '', subs, count=1)
tree = ET.XML(subdata)
xml = tree.find("body").find("div")
@ -118,9 +119,10 @@ class subtitle(object):
def smi(self, subdata):
if requests_version < 0x20300:
subdata = subdata.content
if is_py3:
subdata = subdata.decode("latin")
if is_py2:
subdata = subdata.content
else:
subdata = subdata.content.decode("latin")
else:
subdata.encoding = "ISO-8859-1"
subdata = subdata.text

View File

@ -7,9 +7,10 @@
# pylint: disable=E0611
from __future__ import absolute_import
from svtplay_dl.utils import is_py3
from svtplay_dl.utils import is_py2
if is_py3:
from io import StringIO
else:
if is_py2:
from StringIO import StringIO
else:
from io import StringIO

View File

@ -6,10 +6,10 @@
# pylint: disable=W0611
from __future__ import absolute_import
from svtplay_dl.utils import is_py3
if is_py3:
from svtplay_dl.utils import is_py2
if is_py2:
from urllib import quote, unquote_plus, quote_plus
from urlparse import urlparse, parse_qs, urljoin
else:
# pylint: disable=E0611
from urllib.parse import quote, unquote_plus, quote_plus, urlparse, parse_qs, urljoin
else:
from urllib import quote, unquote_plus, quote_plus
from urlparse import urlparse, parse_qs, urljoin