ffmpeg-update 2.0.0__tar.gz → 2.0.1__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.
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: ffmpeg-update
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: Package manager for FFmpeg, FFprobe, and FFplay static binaries
5
- Keywords: ffmpeg,ffprobe,ffplay,static,binary,manager,installer,downloader,command-line,cli,tool
5
+ Keywords: updater,installer,downloader,binary,program,executable,command,line,cli,tool
6
6
  Author: Asadullah Shaikh
7
7
  Classifier: Topic :: Utilities
8
8
  Classifier: Topic :: Terminals
@@ -22,10 +22,10 @@ Classifier: Intended Audience :: Information Technology
22
22
  Classifier: Development Status :: 5 - Production/Stable
23
23
  Classifier: Programming Language :: Python :: 3
24
24
  Requires-Dist: fire>=0.7.1,<0.8.0
25
- Requires-Dist: requests>=2.32.5,<3.0.0
25
+ Requires-Dist: niquests>=3.15.2,<4.0.0
26
26
  Requires-Dist: tqdm>=4.67.1,<5.0.0
27
27
  Requires-Python: >=3.9
28
- Project-URL: homepage, https://github.com/pantheraleo-7/ffmpeg-update
28
+ Project-URL: Repository, https://github.com/pantheraleo-7/ffmpeg-update
29
29
  Description-Content-Type: text/markdown
30
30
 
31
31
  # FFUp
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ffmpeg-update"
3
- version = "2.0.0"
3
+ version = "2.0.1"
4
4
  description = "Package manager for FFmpeg, FFprobe, and FFplay static binaries"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9"
@@ -8,15 +8,14 @@ authors = [
8
8
  { name = "Asadullah Shaikh" },
9
9
  ]
10
10
  keywords = [
11
- "ffmpeg",
12
- "ffprobe",
13
- "ffplay",
14
- "static",
15
- "binary",
16
- "manager",
11
+ "updater",
17
12
  "installer",
18
13
  "downloader",
19
- "command-line",
14
+ "binary",
15
+ "program",
16
+ "executable",
17
+ "command",
18
+ "line",
20
19
  "cli",
21
20
  "tool",
22
21
  ]
@@ -39,10 +38,10 @@ classifiers = [
39
38
  "Development Status :: 5 - Production/Stable",
40
39
  "Programming Language :: Python :: 3",
41
40
  ]
42
- urls = { homepage = "https://github.com/pantheraleo-7/ffmpeg-update" }
41
+ urls = { Repository = "https://github.com/pantheraleo-7/ffmpeg-update" }
43
42
  dependencies = [
44
43
  "fire>=0.7.1,<0.8.0",
45
- "requests>=2.32.5,<3.0.0",
44
+ "niquests>=3.15.2,<4.0.0",
46
45
  "tqdm>=4.67.1,<5.0.0",
47
46
  ]
48
47
 
@@ -1,3 +1,4 @@
1
+ import io
1
2
  import os as os_
2
3
  import platform
3
4
  import re
@@ -8,7 +9,7 @@ import zipfile
8
9
  from pathlib import Path
9
10
 
10
11
  import fire
11
- import requests
12
+ import niquests
12
13
  from tqdm import tqdm
13
14
 
14
15
 
@@ -35,10 +36,13 @@ class FFUp:
35
36
  or ("arm64" if platform.machine() in ["arm64", "aarch64"] else "amd64")
36
37
  )
37
38
  self.build = build or os_.getenv("FFUP_BUILD") or "snapshot"
38
- self._TMPDIR = tempfile.TemporaryDirectory()
39
+
40
+ self._client = niquests.Session(base_url="https://ffmpeg.martin-riedl.de")
41
+ self._tmpdir = tempfile.TemporaryDirectory()
39
42
 
40
43
  def __del__(self):
41
- self._TMPDIR.cleanup()
44
+ self._client.close()
45
+ self._tmpdir.cleanup()
42
46
 
43
47
  def install(self, *bins):
44
48
  for bin in self._get_bins(bins):
@@ -46,7 +50,7 @@ class FFUp:
46
50
  path = self.dir / bin
47
51
 
48
52
  print("Installing:", bin)
49
- file = self._download(url)
53
+ file = self._download(url, bin)
50
54
  self._install(file, path)
51
55
  print("Installed:", path)
52
56
 
@@ -71,7 +75,7 @@ class FFUp:
71
75
  if current_version != latest_version:
72
76
  print("Update available")
73
77
  if not dry_run:
74
- file = self._download(url)
78
+ file = self._download(url, bin)
75
79
  self._install(file, path)
76
80
  print("Updated:", path)
77
81
  else:
@@ -84,7 +88,7 @@ class FFUp:
84
88
  return set(bins) or {os_.getenv("FFUP_BIN") or "ffmpeg"}
85
89
 
86
90
  def _get_url(self, bin):
87
- return f"https://ffmpeg.martin-riedl.de/redirect/latest/{self.os}/{self.arch}/{self.build}/{bin}.zip"
91
+ return f"/redirect/latest/{self.os}/{self.arch}/{self.build}/{bin}.zip"
88
92
 
89
93
  def _current(self, path):
90
94
  output = subprocess.check_output([path, "-version"], text=True)
@@ -100,8 +104,7 @@ class FFUp:
100
104
  return match.group(1)
101
105
 
102
106
  def _latest(self, url):
103
- response = requests.get(url, allow_redirects=False)
104
-
107
+ response = self._client.get(url, allow_redirects=False)
105
108
  response.raise_for_status()
106
109
  if response.status_code == 307:
107
110
  match = re.search(
@@ -120,32 +123,29 @@ class FFUp:
120
123
  print("Error: unexpected", response, file=sys.stderr)
121
124
  sys.exit(1)
122
125
 
123
- def _download(self, url):
124
- with requests.get(url, stream=True) as response:
125
- response.raise_for_status()
126
- bar = tqdm(
127
- desc="Downloading",
128
- total=int(response.headers["content-length"]),
129
- unit="B",
130
- unit_scale=True,
131
- dynamic_ncols=True,
132
- )
133
- file = Path(self._TMPDIR.name, "ff.zip")
134
- with file.open("wb") as zf:
135
- for chunk in response.iter_content(chunk_size=4096):
136
- chunk_size = zf.write(chunk)
137
- bar.update(chunk_size)
138
- return file
126
+ def _download(self, url, bin):
127
+ response = self._client.get(url, stream=True)
128
+ response.raise_for_status()
129
+ bar = tqdm(
130
+ desc="Downloading",
131
+ total=int(response.headers["content-length"]),
132
+ unit="B",
133
+ unit_scale=True,
134
+ dynamic_ncols=True,
135
+ )
136
+ with io.BytesIO() as buf:
137
+ for chunk in response.iter_content():
138
+ chunk_size = buf.write(chunk)
139
+ bar.update(chunk_size)
140
+ with zipfile.ZipFile(buf) as zf:
141
+ return zf.extract(bin, self._tmpdir.name)
139
142
 
140
143
  def _install(self, file, path):
141
- with zipfile.ZipFile(file, "r") as zf:
142
- bin = zf.extract(path.name, self._TMPDIR.name)
143
- os_.chmod(bin, 0o755)
144
-
144
+ os_.chmod(file, 0o755)
145
145
  try:
146
- os_.replace(bin, path)
146
+ os_.replace(file, path)
147
147
  except PermissionError:
148
- subprocess.run(["sudo", "mv", bin, path], check=True, capture_output=True)
148
+ subprocess.run(["sudo", "mv", file, path], check=True, capture_output=True)
149
149
 
150
150
  def _uninstall(self, path):
151
151
  try:
File without changes