From: Antonio Ospite Date: Fri, 15 Jan 2016 20:53:05 +0000 (+0100) Subject: smooth-dl.py: update to python3 X-Git-Url: https://git.ao2.it/smooth-dl.git/commitdiff_plain/e5fcd65651d541ee43bd92c7e5eec1a721f2cc0c smooth-dl.py: update to python3 --- diff --git a/smooth-dl.py b/smooth-dl.py index 60c3e00..d983a28 100755 --- a/smooth-dl.py +++ b/smooth-dl.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # smooth-dl - download videos served using Smooth Streaming technology # @@ -34,11 +34,13 @@ import os import re import sys import xml.etree.ElementTree as etree -import urllib2 +import urllib.request +import urllib.error +import urllib.parse import struct import tempfile from optparse import OptionParser -from urlparse import urlparse, urlunparse +from urllib.parse import urlparse, urlunparse __description__ = "Download videos served using Smooth Streaming technology" __version__ = "0.x" @@ -62,11 +64,7 @@ def get_chunk_data(data): def hexstring_to_bytes(hex_string): - res = "" - for i in range(0, len(hex_string), 2): - res += chr(int(hex_string[i:i + 2], 16)) - - return res + return bytearray.fromhex(hex_string) def write_wav_header(out_file, fmt, codec_private_data, data_len): @@ -77,9 +75,9 @@ def write_wav_header(out_file, fmt, codec_private_data, data_len): fmt_len = 18 + fmt['cbSize'] wave_len = len("WAVEfmt ") + 4 + fmt_len + len('data') + 4 - out_file.write("RIFF") + out_file.write(bytes("RIFF", "ascii")) out_file.write(struct.pack('