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

fetcher.http: if we can detect its mp3, use that as extension.

This commit is contained in:
Johan Andersson 2019-01-09 21:34:21 +01:00
parent 806fd55d3b
commit f47e729c01

View File

@ -1,6 +1,7 @@
# ex:ts=4:sw=4:sts=4:et # ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
from __future__ import absolute_import from __future__ import absolute_import
import os
from svtplay_dl.utils.output import ETA, progressbar, output from svtplay_dl.utils.output import ETA, progressbar, output
from svtplay_dl.fetcher import VideoRetriever from svtplay_dl.fetcher import VideoRetriever
@ -13,7 +14,11 @@ class HTTP(VideoRetriever):
def download(self): def download(self):
""" Get the stream from HTTP """ """ Get the stream from HTTP """
self.output_extention = "mp4" # this might be wrong.. _, ext = os.path.splitext(self.url)
if ext == ".mp3":
self.output_extention = "mp3"
else:
self.output_extention = "mp4" # this might be wrong..
data = self.http.request("get", self.url, stream=True) data = self.http.request("get", self.url, stream=True)
try: try:
total_size = data.headers['content-length'] total_size = data.headers['content-length']
@ -22,7 +27,7 @@ class HTTP(VideoRetriever):
total_size = int(total_size) total_size = int(total_size)
bytes_so_far = 0 bytes_so_far = 0
file_d = output(self.output, self.config, "mp4") file_d = output(self.output, self.config, self.output_extention)
if file_d is None: if file_d is None:
return return