ffmpeg-update 3.0.2__tar.gz → 3.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ffmpeg_update-3.0.2 → ffmpeg_update-3.1.0}/PKG-INFO +1 -1
- {ffmpeg_update-3.0.2 → ffmpeg_update-3.1.0}/pyproject.toml +1 -1
- {ffmpeg_update-3.0.2 → ffmpeg_update-3.1.0}/src/ffmpeg_update/__init__.py +30 -27
- {ffmpeg_update-3.0.2 → ffmpeg_update-3.1.0}/README.md +0 -0
- {ffmpeg_update-3.0.2 → ffmpeg_update-3.1.0}/src/ffmpeg_update/__main__.py +0 -0
- {ffmpeg_update-3.0.2 → ffmpeg_update-3.1.0}/src/ffmpeg_update/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: ffmpeg-update
|
|
3
|
-
Version: 3.0
|
|
3
|
+
Version: 3.1.0
|
|
4
4
|
Summary: Package manager for FFmpeg, FFprobe, and FFplay static binaries
|
|
5
5
|
Keywords: updater,installer,downloader,program,executable,binary,command,line,cli,tool
|
|
6
6
|
Author: Asadullah Shaikh
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import asyncio
|
|
1
2
|
import io
|
|
2
3
|
import platform
|
|
3
4
|
import re
|
|
@@ -11,7 +12,7 @@ from typing import Annotated, Literal
|
|
|
11
12
|
|
|
12
13
|
from cyclopts import App, Parameter
|
|
13
14
|
from cyclopts.types import ResolvedExistingDirectory
|
|
14
|
-
from niquests import
|
|
15
|
+
from niquests import AsyncSession
|
|
15
16
|
from rich import print
|
|
16
17
|
from rich.progress import Progress
|
|
17
18
|
|
|
@@ -29,7 +30,7 @@ app.register_install_completion_command(add_to_startup=False)
|
|
|
29
30
|
|
|
30
31
|
|
|
31
32
|
@app.meta.default
|
|
32
|
-
def ffup(
|
|
33
|
+
async def ffup(
|
|
33
34
|
*tokens: Annotated[str, Parameter(show=False, allow_leading_hyphen=True)],
|
|
34
35
|
dir: Annotated[
|
|
35
36
|
ResolvedExistingDirectory, Parameter(env_var=("FFUP_DIR", "XDG_BIN_HOME"))
|
|
@@ -54,15 +55,15 @@ def ffup(
|
|
|
54
55
|
arch = get_arch() if arch is None else arch
|
|
55
56
|
os = get_os() if os is None else os
|
|
56
57
|
|
|
57
|
-
additional_kwargs["client"] =
|
|
58
|
+
additional_kwargs["client"] = AsyncSession(
|
|
58
59
|
base_url=f"https://ffmpeg.martin-riedl.de/redirect/latest/{os}/{arch}/{build}/"
|
|
59
60
|
)
|
|
60
61
|
|
|
61
|
-
return command(*bound.args, **bound.kwargs, **additional_kwargs)
|
|
62
|
+
return await command(*bound.args, **bound.kwargs, **additional_kwargs)
|
|
62
63
|
|
|
63
64
|
|
|
64
65
|
@app.command
|
|
65
|
-
def update(
|
|
66
|
+
async def update(
|
|
66
67
|
bins: set[BinType] = {"ffmpeg"},
|
|
67
68
|
/,
|
|
68
69
|
*,
|
|
@@ -70,53 +71,55 @@ def update(
|
|
|
70
71
|
dir: Annotated[ResolvedExistingDirectory, Parameter(parse=False)],
|
|
71
72
|
tempdir: Annotated[TemporaryDirectory[str], Parameter(parse=False)],
|
|
72
73
|
progress: Annotated[Progress, Parameter(parse=False)],
|
|
73
|
-
client: Annotated[
|
|
74
|
+
client: Annotated[AsyncSession, Parameter(parse=False)],
|
|
74
75
|
) -> None:
|
|
75
76
|
with progress:
|
|
76
|
-
for bin in bins:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
latest = _latest(bin, client)
|
|
77
|
+
for bin in bins.copy():
|
|
78
|
+
current = _current(dir / bin)
|
|
79
|
+
latest = await _latest(bin, client)
|
|
80
80
|
print(f"{_fmt_FF(bin)}:\n\tCurrent: {current}\n\tLatest: {latest}")
|
|
81
81
|
if current != latest:
|
|
82
82
|
print(f"{_fmt_FF(bin)}: update available")
|
|
83
|
-
if not dry_run:
|
|
84
|
-
file = _download(bin, tempdir, progress, client)
|
|
85
|
-
_install(file, path)
|
|
86
|
-
print("Updated:", path)
|
|
87
83
|
else:
|
|
84
|
+
bins.remove(bin)
|
|
88
85
|
print(f"{_fmt_FF(bin)}: up to date")
|
|
89
86
|
|
|
87
|
+
if not dry_run and bins:
|
|
88
|
+
await install(
|
|
89
|
+
bins, dir=dir, tempdir=tempdir, progress=progress, client=client
|
|
90
|
+
)
|
|
91
|
+
|
|
90
92
|
|
|
91
93
|
@app.command
|
|
92
|
-
def check(
|
|
94
|
+
async def check(
|
|
93
95
|
bins: set[BinType] = {"ffmpeg"},
|
|
94
96
|
/,
|
|
95
97
|
*,
|
|
96
98
|
dir: Annotated[ResolvedExistingDirectory, Parameter(parse=False)],
|
|
97
99
|
tempdir: Annotated[TemporaryDirectory[str], Parameter(parse=False)],
|
|
98
100
|
progress: Annotated[Progress, Parameter(parse=False)],
|
|
99
|
-
client: Annotated[
|
|
101
|
+
client: Annotated[AsyncSession, Parameter(parse=False)],
|
|
100
102
|
):
|
|
101
|
-
update(
|
|
103
|
+
await update(
|
|
102
104
|
bins, dry_run=True, dir=dir, tempdir=tempdir, progress=progress, client=client
|
|
103
105
|
)
|
|
104
106
|
|
|
105
107
|
|
|
106
108
|
@app.command
|
|
107
|
-
def install(
|
|
109
|
+
async def install(
|
|
108
110
|
bins: set[BinType] = {"ffmpeg"},
|
|
109
111
|
/,
|
|
110
112
|
*,
|
|
111
113
|
dir: Annotated[ResolvedExistingDirectory, Parameter(parse=False)],
|
|
112
114
|
tempdir: Annotated[TemporaryDirectory[str], Parameter(parse=False)],
|
|
113
115
|
progress: Annotated[Progress, Parameter(parse=False)],
|
|
114
|
-
client: Annotated[
|
|
116
|
+
client: Annotated[AsyncSession, Parameter(parse=False)],
|
|
115
117
|
) -> None:
|
|
116
118
|
with progress:
|
|
117
|
-
for
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
for file in await asyncio.gather(
|
|
120
|
+
*[_download(bin, tempdir, progress, client) for bin in bins]
|
|
121
|
+
):
|
|
122
|
+
path = dir / file.name
|
|
120
123
|
_install(file, path)
|
|
121
124
|
print("Installed:", path)
|
|
122
125
|
|
|
@@ -164,8 +167,8 @@ def _current(path):
|
|
|
164
167
|
return match.group(1)
|
|
165
168
|
|
|
166
169
|
|
|
167
|
-
def _latest(bin, client):
|
|
168
|
-
response = client.get(f"{bin}.zip", allow_redirects=False)
|
|
170
|
+
async def _latest(bin, client):
|
|
171
|
+
response = await client.get(f"{bin}.zip", allow_redirects=False)
|
|
169
172
|
response.raise_for_status()
|
|
170
173
|
if response.status_code == 307:
|
|
171
174
|
match = re.search(r"_(N-\d+-\w+|\d\.\d(\.\d)?)", response.headers["location"])
|
|
@@ -176,12 +179,12 @@ def _latest(bin, client):
|
|
|
176
179
|
raise ValueError(f"unexpected {response}")
|
|
177
180
|
|
|
178
181
|
|
|
179
|
-
def _download(bin, tempdir, progress, client):
|
|
180
|
-
response = client.get(f"{bin}.zip", stream=True)
|
|
182
|
+
async def _download(bin, tempdir, progress, client):
|
|
183
|
+
response = await client.get(f"{bin}.zip", stream=True)
|
|
181
184
|
response.raise_for_status()
|
|
182
185
|
id = progress.add_task(_fmt_FF(bin), total=int(response.headers["content-length"]))
|
|
183
186
|
with io.BytesIO() as buf:
|
|
184
|
-
for chunk in response.iter_content():
|
|
187
|
+
async for chunk in await response.iter_content():
|
|
185
188
|
chunk_size = buf.write(chunk)
|
|
186
189
|
progress.update(id, advance=chunk_size)
|
|
187
190
|
progress.update(id, visible=False)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|