From e5fcd65651d541ee43bd92c7e5eec1a721f2cc0c Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 15 Jan 2016 21:53:05 +0100 Subject: [PATCH] smooth-dl.py: update to python3 --- smooth-dl.py | 72 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 37 deletions(-) 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('