- 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):
def write_wav_header(out_file, fmt, codec_private_data, data_len):
out_file.write(struct.pack('<L', fmt_len))
out_file.write(struct.pack('<H', fmt['wFormatTag']))
out_file.write(struct.pack('<H', fmt['nChannels']))
out_file.write(struct.pack('<L', fmt_len))
out_file.write(struct.pack('<H', fmt['wFormatTag']))
out_file.write(struct.pack('<H', fmt['nChannels']))
out_file.write(struct.pack('<H', fmt['wBitsPerSample']))
out_file.write(struct.pack('<H', fmt['cbSize']))
out_file.write(extradata)
out_file.write(struct.pack('<H', fmt['wBitsPerSample']))
out_file.write(struct.pack('<H', fmt['cbSize']))
out_file.write(extradata)
manifest_url += '/Manifest'
local_manifest_path = os.path.join(dest_dir, 'Manifest')
manifest_url += '/Manifest'
local_manifest_path = os.path.join(dest_dir, 'Manifest')
for i, s in enumerate(streams):
stream_type = s.attrib["Type"]
for i, s in enumerate(streams):
stream_type = s.attrib["Type"]
qualities = s.findall("QualityLevel")
for i, q in enumerate(qualities):
bitrate = q.attrib["Bitrate"]
qualities = s.findall("QualityLevel")
for i, q in enumerate(qualities):
bitrate = q.attrib["Bitrate"]
if stream_type == "video":
size = "%sx%s" % (q.attrib["MaxWidth"], q.attrib["MaxHeight"])
if stream_type == "video":
size = "%sx%s" % (q.attrib["MaxWidth"], q.attrib["MaxHeight"])
- print "\t%2s: %4s %10s @ %7s bps" % (i, fourcc, size, bitrate)
+ print("\t%2s: %4s %10s @ %7s bps" % (i, fourcc, size, bitrate))
if stream_type == "audio":
channels = q.attrib["Channels"]
sampling_rate = q.attrib["SamplingRate"]
bits_per_sample = q.attrib["BitsPerSample"]
if stream_type == "audio":
channels = q.attrib["Channels"]
sampling_rate = q.attrib["SamplingRate"]
bits_per_sample = q.attrib["BitsPerSample"]
- print "\t%2s: %4s %sHz %sbits %sch @ %7s bps" % \
- (i, fourcc, sampling_rate, bits_per_sample, channels,
- bitrate)
+ print("\t%2s: %4s %sHz %sbits %sch @ %7s bps" %
+ (i, fourcc, sampling_rate, bits_per_sample, channels,
+ bitrate))
chunks_dest_dir = os.path.join(dest_dir, chunks_quality)
if not os.path.exists(chunks_dest_dir):
chunks_dest_dir = os.path.join(dest_dir, chunks_quality)
if not os.path.exists(chunks_dest_dir):
- print "\nDownloading Stream %d" % stream_index
- print "\tChunks %10d/%-10d" % (0, len(chunks)), "\r",
+ print("\nDownloading Stream %d" % stream_index)
+ print("\tChunks %10d/%-10d" % (0, len(chunks)), "\r", end=' ')
- print "\tChunks %10d/%-10d" % (i + 1, len(chunks)), "\r",
+ print("\tChunks %10d/%-10d" % (i + 1, len(chunks)), "\r", end=' ')
def rebuild_stream(manifest, stream_index, quality_level, src_dir,
def rebuild_stream(manifest, stream_index, quality_level, src_dir,
- print "\nRebuilding Stream %d" % stream_index
- print "\tChunks %10d/%-10d" % (0, len(chunks)), "\r",
+ print("\nRebuilding Stream %d" % stream_index)
+ print("\tChunks %10d/%-10d" % (0, len(chunks)), "\r", end=' ')
- print "\tChunks %10d/%-10d" % (i + 1, len(chunks)), "\r",
+ print("\tChunks %10d/%-10d" % (i + 1, len(chunks)), "\r", end=' ')
fmt['wFormatTag'] = int(quality.attrib['AudioTag'])
fmt['nChannels'] = int(quality.attrib['Channels'])
fmt['nSamplesPerSec'] = int(quality.attrib['SamplingRate'])
fmt['wFormatTag'] = int(quality.attrib['AudioTag'])
fmt['nChannels'] = int(quality.attrib['Channels'])
fmt['nSamplesPerSec'] = int(quality.attrib['SamplingRate'])
fmt['wBitsPerSample'] = int(quality.attrib['BitsPerSample'])
fmt['nBlockAlign'] = int(quality.attrib['PacketSize'])
fmt['cbSize'] = 0
fmt['wBitsPerSample'] = int(quality.attrib['BitsPerSample'])
fmt['nBlockAlign'] = int(quality.attrib['PacketSize'])
fmt['cbSize'] = 0
" -vcodec copy -acodec copy ffout.mkv") % \
(dest_video, delay, dest_audio + '.wav')
" -vcodec copy -acodec copy ffout.mkv") % \
(dest_video, delay, dest_audio + '.wav')