aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rwxr-xr-xautomedia.py9
-rwxr-xr-xdomain.py17
-rw-r--r--requirements.txt3
4 files changed, 25 insertions, 6 deletions
diff --git a/README.md b/README.md
index 03da144..6c55c08 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ Run automedia without any options to see all options.
## System
transmission-cli, notify-send (optional)
## Python
-feedparser, tldextract, transmissionrpc
+feedparser, transmissionrpc
# Requirements when using read_manga.py
## System
rofi, sxiv
diff --git a/automedia.py b/automedia.py
index 2585aab..9bd142d 100755
--- a/automedia.py
+++ b/automedia.py
@@ -7,10 +7,10 @@ import sys
import time
import json
import uuid
-# TODO: Remove this shit. It gives warning and it's slow
-import tldextract
import transmissionrpc
+from domain import url_extract_domain
+
from lxml import etree
from datetime import datetime
@@ -319,7 +319,10 @@ def add_rss(name, url, rss_config_dir, start_after):
return True
def add_html(name, url, html_config_dir, start_after):
- domain = tldextract.extract(url).domain
+ domain = url_extract_domain(url)
+ if len(domain) == 0:
+ print("Invalid url: {}".format(url))
+ return False
domain_plugin_path = os.path.join(script_dir, "plugins", domain)
domain_plugin_py_path = os.path.join(script_dir, "plugins", domain + ".py")
diff --git a/domain.py b/domain.py
new file mode 100755
index 0000000..9f39efc
--- /dev/null
+++ b/domain.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+def url_extract_domain(url):
+ index = 0
+ if url.startswith("http://"):
+ index += 7
+ elif url.startswith("https://"):
+ index += 8
+
+ if url.startswith("www.", index):
+ index += 4
+
+ end = url.find(".", index)
+ if end == -1:
+ return url[index:]
+ else:
+ return url[index:end]
diff --git a/requirements.txt b/requirements.txt
index 7b5672d..2951ed3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,2 @@
feedparser
-tldextract
-transmissionrpc \ No newline at end of file
+transmissionrpc