Add support for output mode "tts-ready"

master
Felix Stupp 2 years ago
parent da1b4608e5
commit fe1db6251e
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -3,6 +3,7 @@
import argparse import argparse
from enum import Enum from enum import Enum
from getpass import getpass from getpass import getpass
from html.parser import HTMLParser
import json import json
import os import os
import re import re
@ -18,6 +19,7 @@ APP_NAME = "tinytinypy" # For default config directories
class OutputMode(Enum): class OutputMode(Enum):
# enum values # enum values
JSON = ('json', False) JSON = ('json', False)
TTS_READY = ('tts-ready', True)
ONLY_URL = ('only-url', False) ONLY_URL = ('only-url', False)
HEADLINES = ('headlines', False) HEADLINES = ('headlines', False)
# helpers # helpers
@ -41,6 +43,15 @@ def func_articles(server, args):
if args.output_mode == OutputMode.ONLY_URL: if args.output_mode == OutputMode.ONLY_URL:
for h in headlines: for h in headlines:
print(h.url) print(h.url)
elif args.output_mode == OutputMode.TTS_READY:
for h in headlines:
if h.content:
parser = ContentTTSParser()
parser.append_sentence(h.title)
parser.feed(h.content)
print(parser.extracted)
else:
print(h.title)
elif args.output_mode == OutputMode.HEADLINES: elif args.output_mode == OutputMode.HEADLINES:
for h in headlines: for h in headlines:
print(h.title) print(h.title)

Loading…
Cancel
Save