mirror of
https://github.com/Benexl/FastAnime.git
synced 2025-12-06 12:51:08 -08:00
fix(interfaces): episode previews
This commit is contained in:
@@ -103,7 +103,6 @@ def write_search_results(
|
|||||||
titles: sanitized anime titles
|
titles: sanitized anime titles
|
||||||
workers:number of threads to use defaults to as many as possible
|
workers:number of threads to use defaults to as many as possible
|
||||||
"""
|
"""
|
||||||
# NOTE: Will probably make this a configuraable option
|
|
||||||
# use concurency to download and write as fast as possible
|
# use concurency to download and write as fast as possible
|
||||||
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
|
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
|
||||||
future_to_task = {}
|
future_to_task = {}
|
||||||
@@ -285,7 +284,7 @@ def get_fzf_episode_preview(
|
|||||||
anilist_results: the anilist results from an anilist action
|
anilist_results: the anilist results from an anilist action
|
||||||
"""
|
"""
|
||||||
|
|
||||||
HEADER_COLOR = 215, 0, 95
|
# HEADER_COLOR = 215, 0, 95
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def _worker():
|
def _worker():
|
||||||
@@ -293,18 +292,16 @@ def get_fzf_episode_preview(
|
|||||||
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
|
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
|
||||||
# load the jobs
|
# load the jobs
|
||||||
future_to_url = {}
|
future_to_url = {}
|
||||||
|
|
||||||
for episode in episodes:
|
for episode in episodes:
|
||||||
episode_title = ""
|
episode_title = ""
|
||||||
image_url = ""
|
image_url = ""
|
||||||
for episode_detail in anilist_result["streamingEpisodes"]:
|
for episode_detail in anilist_result["streamingEpisodes"]:
|
||||||
if re.match(f"Episode {episode} ", episode_detail["title"]):
|
if re.match(f".*Episode {episode} .*", episode_detail["title"]):
|
||||||
episode_title = episode_detail["title"]
|
episode_title = episode_detail["title"]
|
||||||
image_url = episode_detail["thumbnail"]
|
image_url = episode_detail["thumbnail"]
|
||||||
|
|
||||||
if episode_title and image_url:
|
if episode_title and image_url:
|
||||||
# actual link to download image from
|
|
||||||
if not image_url:
|
|
||||||
continue
|
|
||||||
future_to_url[
|
future_to_url[
|
||||||
executor.submit(save_image_from_url, image_url, episode)
|
executor.submit(save_image_from_url, image_url, episode)
|
||||||
] = image_url
|
] = image_url
|
||||||
@@ -315,13 +312,25 @@ def get_fzf_episode_preview(
|
|||||||
echo -n -e "{get_true_fg("─",*SEPARATOR_COLOR,bold=False)}"
|
echo -n -e "{get_true_fg("─",*SEPARATOR_COLOR,bold=False)}"
|
||||||
((ll++))
|
((ll++))
|
||||||
done
|
done
|
||||||
echo "{get_true_fg('Anime Title:',*HEADER_COLOR)} {(anilist_result['title']['romaji'] or anilist_result['title']['english']).replace('"',SINGLE_QUOTE)}"
|
echo "{get_true_fg('Anime Title(eng):',*HEADER_COLOR)} {('' or anilist_result['title']['english']).replace('"',SINGLE_QUOTE)}"
|
||||||
echo "{get_true_fg('Episode Title:',*HEADER_COLOR)} {str(episode_title).replace('"',SINGLE_QUOTE)}"
|
echo "{get_true_fg('Anime Title(jp):',*HEADER_COLOR)} {(anilist_result['title']['romaji'] or '').replace('"',SINGLE_QUOTE)}"
|
||||||
|
|
||||||
|
ll=2
|
||||||
|
while [ $ll -le $FZF_PREVIEW_COLUMNS ];do
|
||||||
|
echo -n -e "{get_true_fg("─",*SEPARATOR_COLOR,bold=False)}"
|
||||||
|
((ll++))
|
||||||
|
done
|
||||||
|
echo "{str(episode_title).replace('"',SINGLE_QUOTE)}"
|
||||||
|
ll=2
|
||||||
|
while [ $ll -le $FZF_PREVIEW_COLUMNS ];do
|
||||||
|
echo -n -e "{get_true_fg("─",*SEPARATOR_COLOR,bold=False)}"
|
||||||
|
((ll++))
|
||||||
|
done
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
future_to_url[
|
future_to_url[
|
||||||
executor.submit(save_info_from_str, template, episode)
|
executor.submit(save_info_from_str, template, str(episode))
|
||||||
] = episode_title
|
] = str(episode)
|
||||||
|
|
||||||
# execute the jobs
|
# execute the jobs
|
||||||
for future in concurrent.futures.as_completed(future_to_url):
|
for future in concurrent.futures.as_completed(future_to_url):
|
||||||
@@ -371,14 +380,15 @@ def get_fzf_episode_preview(
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
preview = """
|
preview = """
|
||||||
|
title={}
|
||||||
%s
|
%s
|
||||||
show_image_previews="%s"
|
show_image_previews="%s"
|
||||||
if [ $show_image_previews = "true" ];then
|
if [ $show_image_previews = "true" ];then
|
||||||
if [ -s %s/{} ]; then fzf-preview %s/{}
|
if [ -s %s/${title}.png ]; then fzf-preview %s/${title}.png
|
||||||
else echo Loading...
|
else echo Loading...
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -s %s/{} ]; then source %s/{}
|
if [ -f %s/${title} ]; then source %s/${title}
|
||||||
else echo Loading...
|
else echo Loading...
|
||||||
fi
|
fi
|
||||||
""" % (
|
""" % (
|
||||||
|
|||||||
Reference in New Issue
Block a user