diff options
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | automedia | bin | 116632 -> 116632 bytes | |||
-rwxr-xr-x | list-by-updated.sh | 10 | ||||
-rw-r--r-- | src/episode.c | 29 | ||||
-rw-r--r-- | src/episode.h | 1 |
5 files changed, 34 insertions, 8 deletions
@@ -12,6 +12,8 @@ Run automedia without any options to see all options. 3. Cache string lengths (too many strcat). 4. Convert python plugins to C. 5. Use torrent add response to track finished torrents. A torrent can finish before it is first checked! +6. Add rate limiting for downloading manga. +7. Verify path lengths. Currently there is limit to 255 characters for remote names, but not local + remote names. # Requirements ## System curl, transmission-cli, notify-send (optional) Binary files differdiff --git a/list-by-updated.sh b/list-by-updated.sh new file mode 100755 index 0000000..86780ea --- /dev/null +++ b/list-by-updated.sh @@ -0,0 +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") +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" +done diff --git a/src/episode.c b/src/episode.c index 67ec5ba..b74417a 100644 --- a/src/episode.c +++ b/src/episode.c @@ -77,7 +77,16 @@ int episode_info_create_from_episode_name(EpisodeInfo *self, const char *episode self->anime_name = strip(self->anime_name); episode_name_offset += anime_name_len + 1; - int resolution_index = string_find(episode_name_stripped, episode_name_stripped_len, last_dash + 1, '['); + int resolution_index_bracket = string_find(episode_name_stripped, episode_name_stripped_len, last_dash + 1, '['); + int resolution_index_parentheses = string_find(episode_name_stripped, episode_name_stripped_len, last_dash + 1, '('); + char resolution_end_char = ']'; + int resolution_index = resolution_index_bracket; + self->resolution_in_brackets = 1; + if(resolution_index_parentheses != -1 && resolution_index_parentheses < resolution_index_bracket) { + resolution_index = resolution_index_parentheses; + resolution_end_char = ')'; + self->resolution_in_brackets = 0; + } if(resolution_index == -1) { /* TODO: Test if this works */ int episode_len = episode_name_stripped_len - (last_dash + 1); @@ -93,13 +102,15 @@ int episode_info_create_from_episode_name(EpisodeInfo *self, const char *episode self->episode = strip(self->episode); episode_name_offset += episode_len + 1; - int resolution_end = string_find(episode_name_stripped, episode_name_stripped_len, resolution_index + 1, ']'); + int resolution_end = string_find(episode_name_stripped, episode_name_stripped_len, resolution_index + 1, resolution_end_char); if(resolution_end != -1) { int resolution_len = resolution_end - (resolution_index + 1); - self->resolution = self->episode_name + episode_name_offset; - memcpy(self->resolution, episode_name_stripped + resolution_index + 1, resolution_len); - self->resolution[resolution_len] = '\0'; - self->resolution = strip(self->resolution); + if(resolution_len != 8 && episode_name_stripped[resolution_end - 1] == 'p') { // resolution_len is 8 when [] is a CRC and not resolution + self->resolution = self->episode_name + episode_name_offset; + memcpy(self->resolution, episode_name_stripped + resolution_index + 1, resolution_len); + self->resolution[resolution_len] = '\0'; + self->resolution = strip(self->resolution); + } } } @@ -112,10 +123,12 @@ int episode_info_get_generic_name(EpisodeInfo *self, char *output_buffer, int ou int bytes_written = 0; if(self->resolution) { + char res_start_symbol = (self->resolution_in_brackets ? '[' : '('); + char res_end_symbol = (self->resolution_in_brackets ? ']' : ')'); if(self->extension) - bytes_written = snprintf(output_buffer, output_buffer_size, "[%s] %s [%s]%s", self->group_name, self->anime_name, self->resolution, self->extension); + bytes_written = snprintf(output_buffer, output_buffer_size, "[%s] %s %c%s%c%s", self->group_name, self->anime_name, res_start_symbol, self->resolution, res_end_symbol, self->extension); else - bytes_written = snprintf(output_buffer, output_buffer_size, "[%s] %s [%s]", self->group_name, self->anime_name, self->resolution); + bytes_written = snprintf(output_buffer, output_buffer_size, "[%s] %s %c%s%c", self->group_name, self->anime_name, res_start_symbol, self->resolution, res_end_symbol); } else { if(self->extension) bytes_written = snprintf(output_buffer, output_buffer_size, "[%s] %s%s", self->group_name, self->anime_name, self->extension); diff --git a/src/episode.h b/src/episode.h index 66c4e8a..3435391 100644 --- a/src/episode.h +++ b/src/episode.h @@ -10,6 +10,7 @@ typedef struct { char *episode; char *resolution; char *extension; + int resolution_in_brackets; } EpisodeInfo; /* Fails if @episode_name is more than 500 characters long or if group or anime name is missing/cant be parsed */ |