Skip to content

Commit

Permalink
Fix not always returning the direct download link
Browse files Browse the repository at this point in the history
  • Loading branch information
AT0myks committed Nov 24, 2022
1 parent fd81e57 commit bf4eaf2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions reolinkfw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from .cramfs import Cramfs
from .tmpfile import TempFile

__version__ = "1.0.0"
__version__ = "1.0.1"

FILES = ("version_file", "version.json", "dvr.xml", "dvr", "router")
INFO_KEYS = ("firmware_version_prefix", "board_type", "board_name", "build_date", "display_type_info", "detail_machine_type", "type")
Expand Down Expand Up @@ -196,24 +196,24 @@ async def direct_download_url(url):


async def get_info(file_or_url):
"""Retreive firmware info from an on-disk file or a URL.
"""Retrieve firmware info from an on-disk file or a URL.
The file or resource may be a ZIP or a PAK.
"""
if is_url(file_or_url):
type_ = "url"
url = await direct_download_url(file_or_url)
zip_or_pak_bytes = await download(url)
file_or_url = await direct_download_url(file_or_url)
zip_or_pak_bytes = await download(file_or_url)
if isinstance(zip_or_pak_bytes, int):
return [{type_: url, "error": zip_or_pak_bytes}]
return [{type_: file_or_url, "error": zip_or_pak_bytes}]
elif is_pak(zip_or_pak_bytes):
paks = [zip_or_pak_bytes]
else:
with io.BytesIO(zip_or_pak_bytes) as f:
if is_zipfile(f):
paks = extract_paks(f)
else:
return [{type_: url, "error": "Not a ZIP or a PAK file"}]
return [{type_: file_or_url, "error": "Not a ZIP or a PAK file"}]
elif is_local_file(file_or_url):
type_ = "file"
if is_zipfile(file_or_url):
Expand Down

0 comments on commit bf4eaf2

Please sign in to comment.