aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--TODO3
-rw-r--r--src/html.c4
-rw-r--r--src/main.c4
-rwxr-xr-xtools/list-missing-unwatched.py2
-rwxr-xr-xtools/list-unwatched.py2
-rwxr-xr-xtools/remove-watched.py63
-rwxr-xr-xtools/track.py2
8 files changed, 74 insertions, 11 deletions
diff --git a/README.md b/README.md
index 084998d..2abe60d 100644
--- a/README.md
+++ b/README.md
@@ -3,8 +3,7 @@ Automatically track new releases of media and download them. Currently works wit
A notification is shown on the screen when a download finishes (if notify-send is installed).\
AutoMedia checks and downloads updates every 15 minutes. Torrents stop seeding after a ratio of 2.0.\
## Installation
-Run `sudo ./install.sh` to install AutoMedia. It will build automedia with musl if installed, otherwise it will use gcc/clang (whichever you have configured as the default). If you are running Arch Linux, then you can find AutoMedia on aur under the name automedia-git (`yay -S automedia-git`).\
-There is also a prebuilt binary of the latest commit for x86_64 systems available at https://dec05eba.com/files/automedia.
+Run `sudo ./install.sh` to install AutoMedia. It will build automedia with musl if installed, otherwise it will use gcc/clang (whichever you have configured as the default). If you are running Arch Linux, then you can find AutoMedia on aur under the name automedia-git (`yay -S automedia-git`).
## Usage
Run automedia with `sync` option and keep it running to track media. You can then use `add` option to add new media to track.\
Removing media from being synced can be done by removing the tracked directory in `~/.config/automedia/rss/tracked` or `~/.config/automedia/html/tracked` or by using `automedia cleanup`.\
@@ -26,4 +25,4 @@ dmenu, sxiv (for manga), mpv (for anime)
Do not move files inside the download directory. If you want to move them, move the whole download directory
when automedia is not running and then set the download directory to the new location when using sync command.
# Dev info
-titles of manga need to be stripped of spaces on both ends and replace all `/` with `_`.
+titles of manga need to be stripped of spaces on both ends and replace all `/` with `_`. \ No newline at end of file
diff --git a/TODO b/TODO
index fb9449b..b60d5f3 100644
--- a/TODO
+++ b/TODO
@@ -10,4 +10,5 @@ Make downloading manga asynchronous, just like torrents. And have timeout for do
Detect if a website is very slow (timeout?) and ignore sync for that website for the current sync. This is to prevent a slow website from preventing all syncs..
Cleanup command should remove torrents from transmission.
Remove dirname because it breaks automedia.pid because it modified /proc/.../cmdline. Should also do readlink on the first arg of cmdline (which doesn't work if automedia is in /usr/bin???). Use socket! look at quickmedia.
-Some mangadex chapters redirect to mangaplus. Those should redirect to the mangaplus plugin. Right now they are simply skipped. \ No newline at end of file
+Some mangadex chapters redirect to mangaplus. Those should redirect to the mangaplus plugin. Right now they are simply skipped.
+Remove torrents when running automedia cleanup. This can be done by removing torrents by anime config data "filename" (in the json file).
diff --git a/src/html.c b/src/html.c
index cb9904e..c0860b5 100644
--- a/src/html.c
+++ b/src/html.c
@@ -327,7 +327,7 @@ int add_html(const char *name, const char *url, char *html_config_dir, char *pro
}
/*
- Create an ".in_progress" file to prevent periodic sync from reading rss data
+ Create an ".in_progress" file to prevent periodic sync from reading html data
before we have finished adding all the data.
*/
remove(in_progress_filepath);
@@ -426,7 +426,7 @@ static int download_html_items_in_reverse(const char *plugin_filepath, Buffer *d
if(result != 0)
fprintf(stderr, "Failed while downloading html, url: %s\n", download_items_it->link);
- const char *notify_args[] = { "notify-send", "-a", "automedia", "-u", result == 0 ? "normal" : "critical", "-t", "10000", "--", result == 0 ? "Download finished" : "Download failed", notify_msg, NULL };
+ const char *notify_args[] = { "notify-send", "-a", "automedia", "-u", result == 0 ? "normal" : "critical", "-t", "3000", "--", result == 0 ? "Download finished" : "Download failed", notify_msg, NULL };
program_exec(notify_args, NULL, NULL);
if(result != 0)
diff --git a/src/main.c b/src/main.c
index c84ca68..a4deda0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -511,7 +511,7 @@ static void torrent_list_check_new_downloads_callback(int id, const char *name,
if(is_finished) {
if(id < unfinished_torrents->size && unfinished_torrents->items[id] == 1) {
unfinished_torrents->items[id] = 0;
- const char *notify_args[] = { "notify-send", "-u", "normal", "-a", "automedia", "-t", "10000", "--", "Download finished", name, NULL };
+ const char *notify_args[] = { "notify-send", "-u", "normal", "-a", "automedia", "-t", "3000", "--", "Download finished", name, NULL };
program_exec(notify_args, NULL, NULL);
char item_path[PATH_MAX];
@@ -562,7 +562,7 @@ static void sync_rss_html(char *rss_config_dir, char *html_config_dir, char *pro
while(automedia_running) {
sync_tracked_rss(&transmission_session, rss_config_dir);
sync_tracked_html(html_config_dir, program_dir, download_dir);
- fprintf(stderr, "Finished syncing rss and html. Syncing again in 15 minutes\n");
+ fprintf(stderr, "Finished syncing rss and html. Syncing again in %d minutes\n", sync_rate_sec / 60);
int check_count = 0;
while(automedia_running && check_count < sync_rate_sec/check_torrent_status_rate_sec) {
diff --git a/tools/list-missing-unwatched.py b/tools/list-missing-unwatched.py
index 980c500..e529acb 100755
--- a/tools/list-missing-unwatched.py
+++ b/tools/list-missing-unwatched.py
@@ -6,7 +6,7 @@ import sys
def show_notification(title, description, urgency):
print("Notification: title: %s, description: %s" % (title, description))
- process = subprocess.Popen(["notify-send", "-a", "automedia", "-t", "10000", "-u", urgency, "--", title, description])
+ process = subprocess.Popen(["notify-send", "-a", "automedia", "-t", "3000", "-u", urgency, "--", title, description])
stdout, stderr = process.communicate()
return process.returncode == 0
diff --git a/tools/list-unwatched.py b/tools/list-unwatched.py
index 874df7b..9c81c2c 100755
--- a/tools/list-unwatched.py
+++ b/tools/list-unwatched.py
@@ -5,7 +5,7 @@ import subprocess
def show_notification(title, description, urgency):
print("Notification: title: %s, description: %s" % (title, description))
- process = subprocess.Popen(["notify-send", "-a", "automedia", "-t", "10000", "-u", urgency, "--", title, description])
+ process = subprocess.Popen(["notify-send", "-a", "automedia", "-t", "3000", "-u", urgency, "--", title, description])
stdout, stderr = process.communicate()
return process.returncode == 0
diff --git a/tools/remove-watched.py b/tools/remove-watched.py
new file mode 100755
index 0000000..a2a5b00
--- /dev/null
+++ b/tools/remove-watched.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+
+import json
+import os
+import sys
+
+def file_get_content_json(filepath):
+ with open(filepath) as f:
+ return json.load(f)
+
+def get_watch_progress(time, duration):
+ if duration == 0:
+ return 0
+ return time / duration
+
+def get_quickmedia_watched_episodes(downloads_dir):
+ watched_episodes = []
+ local_anime_watch_progress_json = file_get_content_json(os.path.expanduser("~/.config/quickmedia/watch-progress/local-anime"))
+ for filename, anime_item in local_anime_watch_progress_json.items():
+ episode_filepath = os.path.join(downloads_dir, filename)
+ time = int(anime_item["time"])
+ duration = int(anime_item["duration"])
+ watch_progress = get_watch_progress(time, duration)
+ if watch_progress >= 0.9:
+ watched_episodes.append(episode_filepath)
+ return watched_episodes
+
+def main(args):
+ if len(args) != 2:
+ print("usage: remove-watched.py <downloads-dir>")
+ print("")
+ print("This script removes anime episodes that you have finished watching with QuickMedia")
+ exit(1)
+
+ downloads_dir = args[1]
+ watched_episodes = get_quickmedia_watched_episodes(downloads_dir)
+
+ print("Files to remove:")
+ removable_files = []
+ for watched_episode in watched_episodes:
+ if os.path.exists(watched_episode):
+ print(" %s" % watched_episode)
+ removable_files.append(watched_episode)
+
+ while True:
+ response = input("Are you sure you want to remove the above %d episode(s)? (y/n): " % len(removable_files))
+ if len(response) < 1:
+ continue
+
+ if response[0] == 'Y' or response[0] == 'y':
+ for filepath in removable_files:
+ try:
+ os.remove(filepath)
+ print("Removed %s" % filepath)
+ except OSError:
+ pass
+ return
+
+ if response[0] == 'N' or response[0] == 'n':
+ print("Cancelled deletion of episodes")
+ return
+
+main(sys.argv) \ No newline at end of file
diff --git a/tools/track.py b/tools/track.py
index d56d8b3..03a5232 100755
--- a/tools/track.py
+++ b/tools/track.py
@@ -7,7 +7,7 @@ import sys
def show_notification(title, description, urgency):
print("Notification: title: %s, description: %s" % (title, description))
- process = subprocess.Popen(["notify-send", "-a", "automedia", "-t", "10000", "-u", urgency, "--", title, description])
+ process = subprocess.Popen(["notify-send", "-a", "automedia", "-t", "3000", "-u", urgency, "--", title, description])
stdout, stderr = process.communicate()
return process.returncode == 0