From 1530f898babb7939b22e4235e981a2cf60cd233f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 16 Oct 2020 07:26:40 +0200 Subject: Mangadex: show search results in same order as website (not timestamp sorted) --- list-by-updated.sh | 10 +++++----- plugins/mangadex.py | 10 +--------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/list-by-updated.sh b/list-by-updated.sh index 86780ea..61b9a0e 100755 --- a/list-by-updated.sh +++ b/list-by-updated.sh @@ -1,10 +1,10 @@ #!/bin/sh -e -for rss_tracked_dir in ~/.config/automedia/rss/tracked/*; do - cat "$rss_tracked_dir/updated" - echo " " $(basename "$rss_tracked_dir") +for tracked_dir in ~/.config/automedia/rss/tracked/* ~/.config/automedia/html/tracked/*; do + cat "$tracked_dir/updated" + echo " " $(basename "$tracked_dir") done | sort -nr | while IFS= read -r line; do timestamp=$(date -d @$(echo "$line" | cut -d' ' -f1)) - rss_tracked_item=$(echo "$line" | cut -d' ' -f2-) - echo "$timestamp" "|" "$rss_tracked_item" + tracked_item=$(echo "$line" | cut -d' ' -f2-) + echo "$timestamp" "|" "$tracked_item" done diff --git a/plugins/mangadex.py b/plugins/mangadex.py index 59956a4..72b28f3 100755 --- a/plugins/mangadex.py +++ b/plugins/mangadex.py @@ -95,18 +95,10 @@ def list_chapters(url, chapter_list_input): exit(2) chapter_json = json_response["chapter"] - chapters = [] - for key, value in chapter_json.items(): - chapters.append((key, value)) - time_now = time.time() - chapters = sorted(chapters, key=chapter_sort_func, reverse=True) prev_chapter_number = "" output_chapters = [] - for chapter_data in chapters: - chapter_id = chapter_data[0] - chapter = chapter_data[1] - + for chapter_id, chapter in chapter_json.items(): timestamp = chapter.get("timestamp", 0) if timestamp > time_now: continue -- cgit v1.2.3