aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2021-07-30 14:39:08 +0000
committerterminaldweller <thabogre@gmail.com>2021-07-30 14:39:08 +0000
commit66456f1680eb08e9da23676a364ad8f84b27f3f8 (patch)
tree20b2985ce4012ab4b3c5816cf65137c3ca21576b
parentadded config for newspaper. added gitpod configs. (diff)
downloaddevourer-66456f1680eb08e9da23676a364ad8f84b27f3f8.tar.gz
devourer-66456f1680eb08e9da23676a364ad8f84b27f3f8.zip
added gtts and readability
-rwxr-xr-xmain.py10
-rw-r--r--pyproject.toml2
-rwxr-xr-xrun.sh2
3 files changed, 11 insertions, 3 deletions
diff --git a/main.py b/main.py
index e5794e1..c72b674 100755
--- a/main.py
+++ b/main.py
@@ -9,6 +9,9 @@ from contextlib import closing
from requests import get
from requests.exceptions import RequestException
from re import findall
+from readability import Document
+from gtts import gTTS
+from datetime import datetime as time
class Argparser(object):
@@ -85,8 +88,11 @@ def main():
try:
a.download()
a.parse()
- # print(a.html)
- print(a.text)
+ doc = Document(a.html)
+ print(doc.summary())
+ if a.text != '':
+ tts = gTTS(a.text)
+ tts.save(time.today().strftime("%b-%d-%Y-%M-%S-%f")+".mp3")
except Exception as e:
logging.exception(e)
diff --git a/pyproject.toml b/pyproject.toml
index f91a38f..8eaddf2 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -9,6 +9,8 @@ license = "GPL3.0"
python = "^3.8"
newspaper3k = "^0.2.8"
beautifulsoup4 = "^4.9.3"
+readability-lxml = "^0.8.1"
+gtts = "^2.2.3"
[tool.poetry.dev-dependencies]
diff --git a/run.sh b/run.sh
index 710ec7f..be3cd55 100755
--- a/run.sh
+++ b/run.sh
@@ -3,7 +3,7 @@ set -e
set -x
# sniff --src https://github.com/coinpride/CryptoList --url | ./main.py > out2.txt
-./main.py --source https://github.com/coinpride/CryptoList > out.txt
+./main.py --source https://github.com/coinpride/CryptoList > out.html
# ./main.py --source https://techurls.com/ > out.txt
# cat out2.txt| pico2wave --wave=out2.wav
# ./main.py --source http://blog.terminaldweller.com > out.txt