[compat] Use compat_open()

This commit is contained in:
dirkf 2023-07-25 00:17:15 +01:00
parent aac33155e4
commit a25e9f3c84
16 changed files with 68 additions and 55 deletions

View file

@ -1,7 +1,6 @@
from __future__ import unicode_literals
import errno
import io
import hashlib
import json
import os.path
@ -14,6 +13,7 @@ import unittest
import youtube_dl.extractor
from youtube_dl import YoutubeDL
from youtube_dl.compat import (
compat_open as open,
compat_os_name,
compat_str,
)
@ -29,10 +29,10 @@ def get_params(override=None):
"parameters.json")
LOCAL_PARAMETERS_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"local_parameters.json")
with io.open(PARAMETERS_FILE, encoding='utf-8') as pf:
with open(PARAMETERS_FILE, encoding='utf-8') as pf:
parameters = json.load(pf)
if os.path.exists(LOCAL_PARAMETERS_FILE):
with io.open(LOCAL_PARAMETERS_FILE, encoding='utf-8') as pf:
with open(LOCAL_PARAMETERS_FILE, encoding='utf-8') as pf:
parameters.update(json.load(pf))
if override:
parameters.update(override)