Skip to content

Commit

Permalink
swap place on py2 and py3 checks
Browse files Browse the repository at this point in the history
  • Loading branch information
spaam committed Jan 27, 2016
1 parent 219a134 commit 3f04ae2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 25 deletions.
5 changes: 2 additions & 3 deletions lib/svtplay_dl/fetcher/hds.py
Expand Up @@ -9,7 +9,7 @@
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
Expand All @@ -25,8 +25,7 @@ def bytes(string=None, encoding="ascii"):

def _chr(temp):
return temp

if is_py3:
else:
def _chr(temp):
return chr(temp)

Expand Down
14 changes: 7 additions & 7 deletions lib/svtplay_dl/output.py
Expand Up @@ -9,7 +9,7 @@
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

Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down
14 changes: 8 additions & 6 deletions lib/svtplay_dl/subtitle/__init__.py
Expand Up @@ -50,10 +50,11 @@ def download(self):
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")
Expand Down Expand Up @@ -118,9 +119,10 @@ def sami(self, subdata):

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
Expand Down
9 changes: 5 additions & 4 deletions lib/svtplay_dl/utils/io.py
Expand Up @@ -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

10 changes: 5 additions & 5 deletions lib/svtplay_dl/utils/urllib.py
Expand Up @@ -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

0 comments on commit 3f04ae2

Please sign in to comment.