mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-27 21:59:17 +01:00
--load-info: Use the fileinput module
It automatically handles the '-' filename as stdin
This commit is contained in:
parent
003c69a84b
commit
31bd39256b
1 changed files with 7 additions and 2 deletions
|
@ -4,8 +4,10 @@
|
||||||
from __future__ import absolute_import, unicode_literals
|
from __future__ import absolute_import, unicode_literals
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
import contextlib
|
||||||
import datetime
|
import datetime
|
||||||
import errno
|
import errno
|
||||||
|
import fileinput
|
||||||
import io
|
import io
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
|
@ -1452,8 +1454,11 @@ class YoutubeDL(object):
|
||||||
return self._download_retcode
|
return self._download_retcode
|
||||||
|
|
||||||
def download_with_info_file(self, info_filename):
|
def download_with_info_file(self, info_filename):
|
||||||
with io.open(info_filename, 'r', encoding='utf-8') as f:
|
with contextlib.closing(fileinput.FileInput(
|
||||||
info = json.load(f)
|
[info_filename], mode='r',
|
||||||
|
openhook=fileinput.hook_encoded('utf-8'))) as f:
|
||||||
|
# FileInput doesn't have a read method, we can't call json.load
|
||||||
|
info = json.loads('\n'.join(f))
|
||||||
try:
|
try:
|
||||||
self.process_ie_result(info, download=True)
|
self.process_ie_result(info, download=True)
|
||||||
except DownloadError:
|
except DownloadError:
|
||||||
|
|
Loading…
Reference in a new issue