Skip to content

Commit 1a01667

Browse files
committed
Merge remote-tracking branch 'origin/dev' into anilist
2 parents 0254f53 + 5b4a859 commit 1a01667

15 files changed

Lines changed: 179 additions & 24 deletions

File tree

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
coverage==7.10.0
1+
coverage==7.10.5
22
djlint==1.36.4
33
fakeredis==2.30.1
44
pytest-django==4.11.1

requirements.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
aiohttp==3.12.14
1+
aiohttp==3.12.15
22
apprise==1.9.3
3-
beautifulsoup4==4.13.4
3+
beautifulsoup4==4.13.5
44
celery==5.5.3
55
croniter==6.0.0
66
Django==5.2.2
7-
django-allauth[socialaccount]==65.10.0
7+
django-allauth[socialaccount]==65.11.0
88
django-celery-beat==2.8.1
99
django-celery-results==2.6.0
1010
django_debug_toolbar==5.2.0
@@ -20,7 +20,7 @@ icalendar==6.3.1
2020
Pillow==11.3.0
2121
psycopg[binary,pool]==3.2.9
2222
python-decouple==3.8
23-
redis[hiredis]==6.2.0
24-
requests==2.32.4
23+
redis[hiredis]==6.4.0
24+
requests==2.32.5
2525
requests-ratelimiter==0.7.0
2626
unidecode==1.4.0

src/app/models.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,23 +486,26 @@ def _sort_in_progress_media(self, media_list, sort_by):
486486
"""Sort in-progress media based on the sort criteria."""
487487
# Define primary sort functions based on sort_by
488488
primary_sort_functions = {
489-
"upcoming": lambda x: (
489+
users.models.HomeSortChoices.UPCOMING: lambda x: (
490490
x.next_event is None,
491491
x.next_event.datetime if x.next_event else None,
492492
),
493-
"title": lambda x: x.item.title.lower(),
494-
"completion": lambda x: (
493+
users.models.HomeSortChoices.RECENT: lambda x: -timezone.datetime.timestamp(
494+
x.progressed_at if x.progressed_at is not None else x.created_at,
495+
),
496+
users.models.HomeSortChoices.COMPLETION: lambda x: (
495497
x.max_progress is None,
496498
-(
497499
x.progress / x.max_progress * 100
498500
if x.max_progress and x.max_progress > 0
499501
else 0
500502
),
501503
),
502-
"episodes_left": lambda x: (
504+
users.models.HomeSortChoices.EPISODES_LEFT: lambda x: (
503505
x.max_progress is None,
504506
(x.max_progress - x.progress if x.max_progress else 0),
505507
),
508+
users.models.HomeSortChoices.TITLE: lambda x: x.item.title.lower(),
506509
}
507510

508511
primary_sort_function = primary_sort_functions[sort_by]

src/app/providers/tmdb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ def process_episodes(season_metadata, episodes_in_db):
549549
"title": episode["name"],
550550
"overview": episode["overview"],
551551
"history": tracked_episodes.get(episode_number, []),
552+
"runtime": get_readable_duration(episode["runtime"]),
552553
},
553554
)
554555
return episodes_metadata

src/app/tests/test_models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ def test_sort_in_progress_media(self):
716716
# Fewer episodes left first
717717
self.assertEqual(sorted_list, [anime1, anime3, anime2])
718718

719+
# Test sort by recent
720+
sorted_list = manager._sort_in_progress_media(anime_list, sort_by="recent")
721+
self.assertEqual(sorted_list, [anime3, anime2, anime1])
722+
719723
def test_annotate_max_progress(self):
720724
"""Test the annotate_max_progress method."""
721725
manager = MediaManager()
@@ -849,6 +853,7 @@ def test_get_in_progress(self):
849853
) # 11 total - 5 offset
850854
self.assertEqual(in_progress[MediaTypes.ANIME.value]["total"], 11)
851855

856+
852857
def test_get_media(self):
853858
"""Test the get_media method."""
854859
manager = MediaManager()

src/app/tests/test_providers.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,20 +218,23 @@ def test_tmdb_process_episodes(self):
218218
"still_path": "/path/to/still1.jpg",
219219
"name": "Pilot",
220220
"overview": "overview of the episode",
221+
"runtime": 23,
221222
},
222223
{
223224
"episode_number": 2,
224225
"air_date": "2008-01-27",
225226
"still_path": "/path/to/still2.jpg",
226227
"name": "Cat's in the Bag...",
227228
"overview": "overview of the episode",
229+
"runtime": 23,
228230
},
229231
{
230232
"episode_number": 3,
231233
"air_date": "2008-02-10",
232234
"still_path": "/path/to/still3.jpg",
233235
"name": "...And the Bag's in the River",
234236
"overview": "overview of the episode",
237+
"runtime": 23,
235238
},
236239
],
237240
}
@@ -413,15 +416,10 @@ def test_hardcover_book(self):
413416
response = hardcover.book("377193")
414417
self.assertEqual(response["title"], "The Great Gatsby")
415418
self.assertEqual(response["details"]["author"], "F. Scott Fitzgerald")
416-
self.assertEqual(response["details"]["publisher"], "Penguin UK")
417-
self.assertEqual(response["details"]["publish_date"], "1920-06-01")
418-
self.assertEqual(response["details"]["number_of_pages"], 217)
419-
self.assertEqual(response["details"]["format"], "Paperback")
420419
# Testing that we have some of the expected genres
421420
self.assertIn("Fiction", response["genres"])
422421
self.assertIn("Young Adult", response["genres"])
423422
self.assertIn("Classics", response["genres"])
424-
# Rating is approximately 4.21 * 2 = 8.42
425423
self.assertAlmostEqual(response["score"], 7.4, delta=0.1)
426424

427425
def test_hardcover_book_unknown(self):

src/integrations/imports/imdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def _lookup_in_tmdb(self, imdb_id, title_type):
232232

233233
media_type = IMDB_TYPE_MAPPING.get(title_type, "")
234234

235-
if media_type == MediaTypes.MOVIE.value and "movie_results" in response:
235+
if media_type == MediaTypes.MOVIE.value and response.get("movie_results"):
236236
movie = response["movie_results"][0]
237237
return {
238238
"media_id": movie["id"],
@@ -241,7 +241,7 @@ def _lookup_in_tmdb(self, imdb_id, title_type):
241241
"media_type": MediaTypes.MOVIE.value,
242242
}
243243

244-
if media_type == MediaTypes.TV.value and "tv_results" in response:
244+
if media_type == MediaTypes.TV.value and response.get("tv_results"):
245245
tv_show = response["tv_results"][0]
246246
return {
247247
"media_id": tv_show["id"],

src/templates/app/media_details.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ <h2 class="text-xl font-bold mb-4">Episodes</h2>
669669
<div>
670670
<h2 class="text-xl font-semibold mb-1 line-clamp-1">{{ episode.title }}</h2>
671671
<p class="text-sm text-gray-400">
672-
Episode {{ episode.episode_number }} • {{ episode.air_date|default_if_none:"Unknown air date" }}
672+
Episode {{ episode.episode_number }} • {{ episode.air_date|default_if_none:"Unknown air date" }}{% if episode.runtime %} • {{ episode.runtime }}{% endif %}
673673
</p>
674674
</div>
675675
<div class="flex space-x-2">

src/templates/users/about.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{% load static %}
55

66
{% block title %}
7-
Account - Yamtrack
7+
About - Yamtrack
88
{% endblock title %}
99

1010
{% block settings_content %}

src/templates/users/advanced.html

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{% extends "users/base.html" %}
2+
3+
{% load socialaccount %}
4+
{% load static %}
5+
6+
{% block title %}
7+
Advanced - Yamtrack
8+
{% endblock title %}
9+
10+
{% block settings_content %}
11+
12+
<div class="space-y-6">
13+
<div class="bg-[#2a2f35] rounded-lg p-6">
14+
<div class="flex items-center mb-5">
15+
<svg xmlns="http://www.w3.org/2000/svg"
16+
width="24"
17+
height="24"
18+
viewBox="0 0 24 24"
19+
fill="none"
20+
stroke="currentColor"
21+
stroke-width="2"
22+
stroke-linecap="round"
23+
stroke-linejoin="round"
24+
class="w-6 h-6 text-indigo-400 mr-3">
25+
<line x1="4" x2="4" y1="21" y2="14" /><line x1="4" x2="4" y1="10" y2="3" /><line x1="12" x2="12" y1="21" y2="12" /><line x1="12" x2="12" y1="8" y2="3" /><line x1="20" x2="20" y1="21" y2="16" /><line x1="20" x2="20" y1="12" y2="3" /><line x1="2" x2="6" y1="14" y2="14" /><line x1="10" x2="14" y1="8" y2="8" /><line x1="18" x2="22" y1="16" y2="16" />
26+
</svg>
27+
<h2 class="text-xl font-semibold">Advanced</h2>
28+
</div>
29+
30+
<div class="bg-[#39404b] p-5 rounded-lg mb-6">
31+
<div class="flex items-center mb-3">
32+
<svg xmlns="http://www.w3.org/2000/svg"
33+
width="24"
34+
height="24"
35+
viewBox="0 0 24 24"
36+
fill="none"
37+
stroke="currentColor"
38+
stroke-width="2"
39+
stroke-linecap="round"
40+
stroke-linejoin="round"
41+
class="w-5 h-5 text-indigo-400 mr-2">
42+
<path d="M10 11v6" />
43+
<path d="M14 11v6" />
44+
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" />
45+
<path d="M3 6h18" />
46+
<path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
47+
</svg>
48+
<h3 class="text-base font-medium">Clear Search Cache</h3>
49+
</div>
50+
<p class="text-gray-400 mb-4 text-sm">
51+
Yamtrack stores your search results in a cache to speed up performance and reduce API calls.
52+
<br>
53+
Normally, these cached results expire automatically after 24 hours.
54+
If your search results appear outdated, you can clear the cache manually.
55+
<br>
56+
Your next search may be slightly slower as fresh data is retrieved.
57+
</p>
58+
<div class="flex space-x-3">
59+
<form method="post" action="{% url 'clear_search_cache' %}">
60+
{% csrf_token %}
61+
<button type="submit"
62+
class="flex items-center px-4 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors text-sm cursor-pointer">
63+
<svg xmlns="http://www.w3.org/2000/svg"
64+
width="24"
65+
height="24"
66+
viewBox="0 0 24 24"
67+
fill="none"
68+
stroke="currentColor"
69+
stroke-width="2"
70+
stroke-linecap="round"
71+
stroke-linejoin="round"
72+
class="w-4 h-4 mr-2">
73+
<path d="M10 11v6" />
74+
<path d="M14 11v6" />
75+
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" />
76+
<path d="M3 6h18" />
77+
<path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
78+
</svg>
79+
Clear Search Cache
80+
</button>
81+
</form>
82+
</div>
83+
</div>
84+
</div>
85+
</div>
86+
87+
{% endblock settings_content %}

0 commit comments

Comments
 (0)