projects
/
smooth-dl.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
46bd7ee
)
smooth-dl.py: support downloading from a local file in download_file()
author
Antonio Ospite <ao2@ao2.it>
Fri, 15 Jan 2016 19:35:12 +0000
(20:35 +0100)
committer
Antonio Ospite <ao2@ao2.it>
Fri, 15 Jan 2016 19:35:12 +0000
(20:35 +0100)
smooth-dl.py
patch
|
blob
|
history
diff --git
a/smooth-dl.py
b/smooth-dl.py
index
a496bc7
..
1488e2c
100755
(executable)
--- a/
smooth-dl.py
+++ b/
smooth-dl.py
@@
-94,12
+94,18
@@
def write_wav_header(out_file, fmt, codec_private_data, data_len):
def download_file(src_url, dest_file, mode):
def download_file(src_url, dest_file, mode):
- try:
- response = urllib2.urlopen(src_url)
- data = response.read()
- except urllib2.HTTPError:
- sys.stderr.write("Error while dowloading URL: %s" % src_url)
- raise
+
+ if os.path.exists(src_url):
+ f = open(src_url, "rb")
+ data = f.read()
+ f.close()
+ else:
+ try:
+ response = urllib2.urlopen(src_url)
+ data = response.read()
+ except urllib2.HTTPError:
+ sys.stderr.write("Error while dowloading URL: %s" % src_url)
+ raise
if dest_file:
f = open(dest_file, mode)
if dest_file:
f = open(dest_file, mode)
@@
-118,11
+124,8
@@
def get_manifest(url, dest_dir):
if not manifest_url.lower().endswith(('/manifest', '.ismc', '.csm')):
manifest_url += '/Manifest'
if not manifest_url.lower().endswith(('/manifest', '.ismc', '.csm')):
manifest_url += '/Manifest'
- if os.path.exists(url):
- local_manifest_path = url
- else:
- local_manifest_path = os.path.join(dest_dir, 'Manifest')
- download_file(manifest_url, local_manifest_path, "w")
+ local_manifest_path = os.path.join(dest_dir, 'Manifest')
+ download_file(manifest_url, local_manifest_path, "w")
manifest = etree.parse(local_manifest_path)
manifest = etree.parse(local_manifest_path)