Cat Feeder  1.0.0
The Cat feeder project
Loading...
Searching...
No Matches
ff_constants.py
Go to the documentation of this file.
1r"""
2# +==== BEGIN CatFeeder =================+
3# LOGO:
4# ..............(..../\
5# ...............)..(.')
6# ..............(../..)
7# ...............\‍(__)|
8# Inspired by Joan Stark
9# source https://www.asciiart.eu/
10# animals/cats
11# /STOP
12# PROJECT: CatFeeder
13# FILE: ff_constants.py
14# CREATION DATE: 19-11-2025
15# LAST Modified: 14:50:38 19-12-2025
16# DESCRIPTION:
17# This is the backend server in charge of making the actual website work.
18# /STOP
19# COPYRIGHT: (c) Cat Feeder
20# PURPOSE: The constants used by the ff download handler.
21# // AR
22# +==== END CatFeeder =================+
23"""
24
25import os
26from typing import Union, Optional
27from functools import partial
28from pathlib import Path as PPath
29
30# Function to extract files based on archive type
31
32FFMPEG_KEY = "ffmpeg"
33FFPROBE_KEY = "ffprobe"
34FFPLAY_KEY = "ffplay"
35
36WINDOWS_KEY = "windows"
37LINUX_KEY = "linux"
38MAC_KEY = "darwin"
39
40FILE_URL_TOKEN = "file_url"
41FILE_PATH_TOKEN = "file_path"
42QUERY_TIMEOUT = 10
43
44CWD = os.getcwd()
45
46
47def process_file_path(*args: Union[str, PPath], cwd: Optional[Union[str, PPath]] = None) -> str:
48 """
49 Convert a list of elements making up a path to a valid system-specific path.
50
51 Args:
52 *args: Path components to join.
53 cwd: Optional base directory to prepend to the path.
54
55 Returns:
56 str: The compiled path.
57 """
58 if isinstance(cwd, str):
59 path = PPath(cwd, *args)
60 else:
61 path = PPath(*args)
62 return str(path)
63
64
65BUNDLE_DOWNLOAD = {
66 FFMPEG_KEY: {
67 WINDOWS_KEY: {
68 "i686": {
69 FILE_URL_TOKEN: "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.zip", # 32-bit Windows
70 FILE_PATH_TOKEN: partial(
71 process_file_path,
72 "downloads", "windows", "ffmpeg-release-i686-static.zip"
73 )
74 },
75 "64": {
76 FILE_URL_TOKEN: "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-x86_64-static.zip", # 64-bit Windows
77 FILE_PATH_TOKEN: partial(
78 process_file_path,
79 "downloads", "windows", "ffmpeg-release-x86_64-static.zip"
80 )
81 }
82 },
83 LINUX_KEY: {
84 "i686": {
85 # 32-bit Linux (x86)
86 FILE_URL_TOKEN: "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.tar.xz",
87 FILE_PATH_TOKEN: partial(
88 process_file_path,
89 "downloads", "linux", "ffmpeg-release-i686-static.tar.xz"
90 )
91 },
92 "64": {
93 FILE_URL_TOKEN: "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz", # 64-bit Linux
94 FILE_PATH_TOKEN: partial(
95 process_file_path,
96 "downloads", "linux", "ffmpeg-release-x86_64-static.tar.xz"
97 )
98 },
99 "arm64": {
100 # 64-bit Linux (arm64)
101 FILE_URL_TOKEN: "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-arm64-static.tar.xz",
102 FILE_PATH_TOKEN: partial(
103 process_file_path,
104 "downloads", "linux", "ffprobe-release-arm64-static.tar.xz"
105 )
106 }
107 },
108 MAC_KEY: {
109 "i686": {
110 FILE_URL_TOKEN: "https://evermeet.cx/ffmpeg/get/zip", # 32-bit macOS
111 FILE_PATH_TOKEN: partial(
112 process_file_path,
113 "downloads", "macos", "ffmpeg-latest.zip"
114 )
115 },
116 "64": {
117 FILE_URL_TOKEN: "https://evermeet.cx/ffmpeg/get/zip", # 64-bit macOS
118 FILE_PATH_TOKEN: partial(
119 process_file_path,
120 "downloads", "macos", "ffmpeg-latest-amd64.zip"
121 )
122 },
123 "arm64": {
124 # 64-bit macOS (arm64),
125 FILE_URL_TOKEN: "https://ffmpeg.martin-riedl.de/redirect/latest/macos/arm64/release/ffmpeg.zip",
126 FILE_PATH_TOKEN: partial(
127 process_file_path,
128 "downloads", "macos", "ffmpeg-latest-arm64.zip"
129 )
130 }
131 },
132 },
133 FFPROBE_KEY: {
134 WINDOWS_KEY: {
135 "i686": {
136 FILE_URL_TOKEN: "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.zip",
137 FILE_PATH_TOKEN: partial(
138 process_file_path,
139 "downloads", "windows", "ffprobe-release-i686-static.zip"
140 )
141 },
142 "64": {
143 FILE_URL_TOKEN: "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-x86_64-static.zip", # 64-bit Windows
144 FILE_PATH_TOKEN: partial(
145 process_file_path,
146 "downloads", "windows", "ffprobe-release-x86_64-static.zip"
147 )
148 }
149 },
150 LINUX_KEY: {
151 "i686": {
152 # 32-bit Linux (x86)
153 FILE_URL_TOKEN: "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.tar.xz",
154 FILE_PATH_TOKEN: partial(
155 process_file_path,
156 "downloads", "linux", "ffprobe-release-i686-static.tar.xz"
157 )
158 },
159 "64": {
160 # 64-bit Linux
161 FILE_URL_TOKEN: "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz",
162 FILE_PATH_TOKEN: partial(
163 process_file_path,
164 "downloads", "linux", "ffprobe_x64.tar.xz"
165 )
166 },
167 "arm64": {
168 # 64-bit Linux (arm 64)
169 FILE_URL_TOKEN: "https://ffmpeg.martin-riedl.de/redirect/latest/linux/arm64/release/ffprobe.zip",
170 FILE_PATH_TOKEN: partial(
171 process_file_path,
172 "downloads", "linux", "ffprobe_arm64.zip"
173 )
174 },
175 },
176 MAC_KEY: {
177 "i686": {
178 FILE_URL_TOKEN: "https://evermeet.cx/ffmpeg/getrelease/ffprobe/zip", # 32-bit macOS
179 FILE_PATH_TOKEN: partial(
180 process_file_path,
181 "downloads", "macos", "ffprobe-latest.zip"
182 )
183 },
184 "64": {
185 FILE_URL_TOKEN: "https://evermeet.cx/ffmpeg/getrelease/ffprobe/zip", # 64-bit macOS
186 FILE_PATH_TOKEN: partial(
187 process_file_path,
188 "downloads", "macos", "ffprobe-latest-amd64.zip"
189 )
190 },
191 "arm64": {
192 # 64-bit macOS (arm64),
193 FILE_URL_TOKEN: "https://ffmpeg.martin-riedl.de/redirect/latest/macos/arm64/release/ffprobe.zip",
194 FILE_PATH_TOKEN: partial(
195 process_file_path,
196 "downloads", "macos", "ffprobe-latest-arm64.zip"
197 )
198 }
199 },
200 },
201 FFPLAY_KEY: {
202 WINDOWS_KEY: {
203 "i686": {
204 FILE_URL_TOKEN: "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-n4.4-32bit-static.zip", # 32-bit Windows
205 FILE_PATH_TOKEN: partial(
206 process_file_path,
207 "downloads", "windows", "ffplay-release-i686-static.zip"
208 )
209 },
210 "64": {
211 FILE_URL_TOKEN: "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-x86_64-static.zip", # 64-bit Windows
212 FILE_PATH_TOKEN: partial(
213 process_file_path,
214 "downloads", "windows", "ffplay-release-x86_64-static.zip"
215 )
216 }
217 },
218 LINUX_KEY: {
219 "i686": {
220 # 32-bit Linux (x86)
221 FILE_URL_TOKEN: "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.tar.xz",
222 FILE_PATH_TOKEN: partial(
223 process_file_path,
224 "downloads", "linux", "ffplay-release-i686-static.tar.xz"
225 )
226 },
227 "64": {
228 FILE_URL_TOKEN: "https://ffmpeg.martin-riedl.de/redirect/latest/linux/amd64/release/ffplay.zip", # 64-bit Linux
229 FILE_PATH_TOKEN: partial(
230 process_file_path,
231 "downloads", "linux", "ffplay-latest-amd64.zip"
232 )
233 },
234 "arm64": {
235 FILE_URL_TOKEN: "https://ffmpeg.martin-riedl.de/redirect/latest/linux/arm64/release/ffplay.zip", # 64-bit Linux
236 FILE_PATH_TOKEN: partial(
237 process_file_path,
238 "downloads", "linux", "ffplay-latest-arm64.zip"
239 )
240 }
241 },
242 MAC_KEY: {
243 "i686": {
244 FILE_URL_TOKEN: "https://evermeet.cx/ffmpeg/getrelease/ffplay/zip", # 32-bit macOS
245 FILE_PATH_TOKEN: partial(
246 process_file_path,
247 "downloads", "macos", "ffplay-latest.zip"
248 )
249 },
250 "64": {
251 FILE_URL_TOKEN: "https://evermeet.cx/ffmpeg/getrelease/ffplay/zip", # 64-bit macOS
252 FILE_PATH_TOKEN: partial(
253 process_file_path,
254 "downloads", "macos", "ffplay-latest.zip"
255 )
256 },
257 "arm64": {
258 # 64-bit macOS (arm64)
259 FILE_URL_TOKEN: "https://ffmpeg.martin-riedl.de/redirect/latest/macos/arm64/release/ffplay.zip",
260 FILE_PATH_TOKEN: partial(
261 process_file_path,
262 "downloads", "macos", "ffplay-latest-arm64.zip"
263 )
264 }
265 }
266 }
267}
str process_file_path(*Union[str, PPath] args, Optional[Union[str, PPath]] cwd=None)