Skip to content

Commit 046e595

Browse files
authored
fix: Remove linked proxies from queue (#172)
1 parent f63bb5c commit 046e595

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

resolve_proxy_encoder/queuer/link.py

+19-20
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import os
66
from typing import Tuple, Union
77

8-
from rich import print
8+
from rich import print as pprint
99
from rich.console import Console
1010
from rich.prompt import Confirm, Prompt
1111

@@ -27,7 +27,7 @@ def get_proxy_path():
2727

2828
f = Prompt.ask("Enter path to search for proxies")
2929
if f is None:
30-
print("User cancelled. Exiting.")
30+
pprint("User cancelled. Exiting.")
3131
core.app_exit(0, 0)
3232
return f
3333

@@ -40,14 +40,14 @@ def recurse_dir(root):
4040
all_files = [
4141
os.path.join(root, f) for root, dirs, files in os.walk(root) for f in files
4242
]
43-
print(f"Found {len(all_files)} files in folder {root}")
43+
pprint(f"Found {len(all_files)} files in folder {root}")
4444
return all_files
4545

4646

4747
def filter_files(dir_, extension_whitelist):
4848
"""Filter files by allowed filetype"""
4949

50-
# print(f"{timeline.GetName()} - Video track count: {track_len}")
50+
# pprint(f"{timeline.GetName()} - Video track count: {track_len}")
5151
allowed = [x for x in dir_ if os.path.splitext(x) in extension_whitelist]
5252
return allowed
5353

@@ -181,12 +181,12 @@ def find_and_link_proxies(project, proxy_files) -> Tuple[list, list]:
181181
logger.info(f" -> [yellow]No more clips to link in {timeline_data['name']}")
182182
continue
183183
else:
184-
print("\n")
184+
pprint("\n")
185185
console.rule(
186186
f":mag_right: [cyan bold]Searching timeline '{timeline_data['name']}'",
187187
align="left",
188188
)
189-
print("\n")
189+
pprint("\n")
190190

191191
unlinked_proxies = [x for x in proxy_files if x not in linked]
192192
logger.info(f"Unlinked source count: {len(unlinked_source)}")
@@ -196,7 +196,7 @@ def find_and_link_proxies(project, proxy_files) -> Tuple[list, list]:
196196
logger.info(f"[green]No more proxies to link[/]")
197197
break
198198

199-
print()
199+
pprint()
200200

201201
# This inter-function nested loop thing is a little dank.
202202
linked_, failed_ = _link_proxies(proxy_files, clips)
@@ -226,7 +226,7 @@ def link_proxies_with_mpi(media_list, linkable_types: list = ["Offline", "None"]
226226
"""Iterate through media mutated during script call, attempt to link the source media.
227227
Return all that are not succesfully linked."""
228228

229-
print(f"[cyan]Linking {len(media_list)} proxies.[/]")
229+
pprint(f"[cyan]Linking {len(media_list)} proxies.[/]")
230230

231231
link_success = []
232232
link_fail = []
@@ -264,14 +264,14 @@ def link_proxies_with_mpi(media_list, linkable_types: list = ["Offline", "None"]
264264
link_fail.append(media)
265265

266266
if link_success:
267-
print(f"[green]Succeeded linking: [/]{len(link_success)}")
267+
pprint(f"[green]Succeeded linking: [/]{len(link_success)}")
268268

269269
if link_fail:
270-
print(f"[red]Failed linking: [/]{len(link_fail)}")
270+
pprint(f"[red]Failed linking: [/]{len(link_fail)}")
271271

272-
print()
272+
pprint()
273273

274-
print(f"[green]{len(link_success)} proxy(s) successfully linked.")
274+
pprint(f"[green]{len(link_success)} proxy(s) successfully linked.")
275275

276276
if link_fail:
277277

@@ -284,13 +284,12 @@ def link_proxies_with_mpi(media_list, linkable_types: list = ["Offline", "None"]
284284
x["proxy_status"] = "None"
285285

286286
media_list = [x for x in media_list if x not in link_success]
287+
return media_list
287288

288-
else:
289-
290-
# Queue only those that remain
291-
media_list = [
292-
x for x in media_list if x not in link_success or x not in link_fail
293-
]
289+
# Queue only those that remain
290+
media_list = [
291+
x for x in media_list if all([x not in link_success, x not in link_fail])
292+
]
294293

295294
logger.debug(f"[magenta]Remaining unlinked media: {media_list}")
296295
return media_list
@@ -305,7 +304,7 @@ def main():
305304
r_ = ResolveObjects()
306305
proxy_dir = get_proxy_path()
307306

308-
print(f"Passed directory: '{proxy_dir}'\n")
307+
pprint(f"Passed directory: '{proxy_dir}'\n")
309308

310309
all_files = recurse_dir(proxy_dir)
311310
proxy_files = filter_files(
@@ -314,7 +313,7 @@ def main():
314313
linked = find_and_link_proxies(r_.project, proxy_files)
315314

316315
except Exception as e:
317-
print("ERROR - " + str(e))
316+
pprint("ERROR - " + str(e))
318317

319318

320319
if __name__ == "__main__":

version_constraint_key

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nutty-nightingale
1+
violet-vulture

0 commit comments

Comments
 (0)