Skip to content

Commit

Permalink
Refactored matching.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Casvt committed Dec 3, 2024
1 parent 93f400d commit df94334
Show file tree
Hide file tree
Showing 5 changed files with 241 additions and 259 deletions.
13 changes: 7 additions & 6 deletions backend/features/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,17 @@ def manual_search(
continue

# Decide what is a match and what not
issue_numbers: Dict[float, Union[int, None]] = {
volume_issues = volume.get_issues()
number_to_year: Dict[float, Union[int, None]] = {
i['calculated_issue_number']: extract_year_from_date(i['date'])
for i in volume.get_issues()
for i in volume_issues
}
results = [
MatchedSearchResultData({
**result,
**check_search_result_match(result, volume_id, title,
volume_data.special_version, issue_numbers,
calculated_issue_number, volume_data.year
**check_search_result_match(
result, volume_data, volume_issues,
number_to_year, calculated_issue_number
)
})
for result in search_results
Expand All @@ -305,7 +306,7 @@ def manual_search(
# Sort results; put best result at top
results.sort(key=lambda r: _sort_search_results(
r, title, volume_data.volume_number,
(volume_data.year, issue_numbers.get(
(volume_data.year, number_to_year.get(
calculated_issue_number)), # type: ignore
calculated_issue_number
))
Expand Down
4 changes: 3 additions & 1 deletion backend/implementations/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ def extract_files_from_folder(

volume = Volume(volume_id)
volume_data = volume.get_keys(
('id', 'title', 'year', 'folder')
('id', 'title', 'year', 'volume_number', 'folder', 'special_version')
)
volume_issues = volume.get_issues()
end_year = extract_year_from_date(
volume['last_issue_date'],
volume_data.year
Expand All @@ -75,6 +76,7 @@ def extract_files_from_folder(
folder_extraction_filter(
extract_filename_data(c, False),
volume_data,
volume_issues,
end_year
)
)
Expand Down
11 changes: 5 additions & 6 deletions backend/implementations/getcomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
MediaFireFolderDownload, MegaDownload, PixelDrainDownload,
PixelDrainFolderDownload, WeTransferDownload)
from backend.implementations.download_torrent_clients import TorrentDownload
from backend.implementations.matching import GC_group_filter
from backend.implementations.matching import gc_group_filter
from backend.implementations.naming import generate_issue_name
from backend.implementations.volumes import Volume
from backend.internals.db import get_db
Expand Down Expand Up @@ -412,16 +412,15 @@ def _create_link_paths(
('title', 'year', 'special_version', 'volume_number')
)
last_issue_date = volume['last_issue_date']
volume_issues = volume.get_issues()

link_paths: List[List[DownloadGroup]] = []
for group in download_groups:
if not GC_group_filter(
if not gc_group_filter(
group['info'],
volume_id,
volume_data.title,
volume_data.year,
volume_data,
last_issue_date,
volume_data.special_version
volume_issues
):
continue

Expand Down
Loading

0 comments on commit df94334

Please sign in to comment.