aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-08-09 20:20:06 +0200
committerdec05eba <dec05eba@protonmail.com>2022-08-09 20:20:06 +0200
commit1b6fcd828dc18d6fe105387653352945a51800c1 (patch)
tree8601db90198e84ab703fc27676df074ffe51f213
parent2d1bdbf0cb274118f06dfa501fb77ecf0e5cb57a (diff)
Fix old mangakakalot links, such as evil heart
-rwxr-xr-xautomediabin124936 -> 124944 bytes
-rwxr-xr-xplugins/manganelo.py9
-rw-r--r--src/html.c7
-rw-r--r--src/rss.c7
4 files changed, 21 insertions, 2 deletions
diff --git a/automedia b/automedia
index 06f1339..5d30f75 100755
--- a/automedia
+++ b/automedia
Binary files differ
diff --git a/plugins/manganelo.py b/plugins/manganelo.py
index 4427334..5593fd4 100755
--- a/plugins/manganelo.py
+++ b/plugins/manganelo.py
@@ -121,12 +121,21 @@ def list_chapters(url, chapter_list_input):
tree = redirect_migrated_url(url, tree, False)
chapters = []
+
for element in tree.xpath('//ul[@class="row-content-chapter"]//a'):
element_text = element.text.strip().replace("/", "_")
url = element.attrib.get("href").strip()
if element_text.lower().replace(" ", "") in seen_titles or url in seen_urls:
break
chapters.append({ "name": element_text, "url": url })
+
+ for element in tree.xpath('//div[@class="chapter-list"]//a'):
+ element_text = element.text.strip().replace("/", "_")
+ url = element.attrib.get("href").strip()
+ if element_text.lower().replace(" ", "") in seen_titles or url in seen_urls:
+ break
+ chapters.append({ "name": element_text, "url": url })
+
print(json.dumps(chapters))
def download_chapter(url, download_dir):
diff --git a/src/html.c b/src/html.c
index e8ddd23..cb9904e 100644
--- a/src/html.c
+++ b/src/html.c
@@ -378,6 +378,10 @@ int add_html(const char *name, const char *url, char *html_config_dir, char *pro
return result;
}
+static int int_min(int a, int b) {
+ return a < b ? a : b;
+}
+
static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *download_items_buffer, TrackedHtml *tracked_html, char *html_tracked_dir, const char *download_dir) {
const char *home_dir = get_home_dir();
@@ -398,6 +402,7 @@ static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *d
DownloadItemsData *download_items_it = buffer_end(download_items_buffer);
DownloadItemsData *download_items_end = buffer_begin(download_items_buffer);
+ const size_t num_items_to_download = int_min(download_items_it - download_items_end, MAX_UPDATE_ITEMS);
download_items_it--;
download_items_end--;
int download_item_index = 0;
@@ -436,7 +441,7 @@ static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *d
added_download_items[download_item_index] = download_items_it;
// TODO: What if the download is so fast two items have the same timestamp? Maybe substract by MAX_UPDATE_ITEMS and then add 1 each loop,
// or use milliseconds/microseconds timestamps?
- timestamps[download_item_index] = time(NULL);
+ timestamps[download_item_index] = time(NULL) - num_items_to_download + (download_item_index + 1);
++download_item_index;
}
diff --git a/src/rss.c b/src/rss.c
index cc31610..c8bdd2d 100644
--- a/src/rss.c
+++ b/src/rss.c
@@ -480,6 +480,10 @@ static int rss_parse_sync_callback(const char *title, const char *link, void *us
return 0;
}
+static int int_min(int a, int b) {
+ return a < b ? a : b;
+}
+
static int add_torrents_in_reverse(TransmissionSession *transmission_session, Buffer *download_items_buffer, TrackedRss *tracked_rss, char *rss_tracked_dir) {
int result = 0;
char *torrent_names[MAX_UPDATE_ITEMS];
@@ -491,6 +495,7 @@ static int add_torrents_in_reverse(TransmissionSession *transmission_session, Bu
DownloadItemsData *download_items_it = buffer_end(download_items_buffer);
DownloadItemsData *download_items_end = buffer_begin(download_items_buffer);
+ const size_t num_items_to_download = int_min(download_items_it - download_items_end, MAX_UPDATE_ITEMS);
download_items_it--;
download_items_end--;
int torrent_name_index = 0;
@@ -502,7 +507,7 @@ static int add_torrents_in_reverse(TransmissionSession *transmission_session, Bu
break;
}
added_download_items[torrent_name_index] = download_items_it;
- timestamps[torrent_name_index] = time(NULL);
+ timestamps[torrent_name_index] = time(NULL) - num_items_to_download + (torrent_name_index + 1);
++torrent_name_index;
/* Show notification that download has started? */
}