Compare commits
3 commits
5c8f6b563a
...
686decaccf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
686decaccf |
||
|
|
b22ce29ae1 |
||
|
|
457e2c3315 |
2 changed files with 22 additions and 10 deletions
11
Dockerfile
11
Dockerfile
|
|
@ -1,10 +1,19 @@
|
||||||
|
# DiscoRSS Dockerfile
|
||||||
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
FROM python:3.13.2-alpine3.21
|
FROM python:3.13.2-alpine3.21
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
COPY discorss.py ./
|
COPY discorss.py ./
|
||||||
COPY discorss.conf /etc/
|
RUN mkdir /root/.config
|
||||||
|
RUN mkdir /root/.config/discorss
|
||||||
|
COPY discorss.conf /root/.config/discorss
|
||||||
|
|
||||||
RUN pip install --no-cache-dir requests feedparser
|
RUN pip install --no-cache-dir requests feedparser
|
||||||
|
|
||||||
CMD [ "python", "discorss.py" ]
|
CMD [ "python", "discorss.py" ]
|
||||||
|
|
||||||
|
LABEL author="A.M. Rowsell <https://frzn.dev/~amr>"
|
||||||
|
|
|
||||||
19
discorss.py
19
discorss.py
|
|
@ -8,7 +8,7 @@
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
# DiscoRSS: A simple RSS feed reader for Discord. Takes RSS feeds and then sends them to
|
# DiscoRSS: A simple RSS feed reader for Discord. Takes RSS feeds and then sends them to
|
||||||
# webhooks. Intended to run using systemd timers.
|
# webhooks. Intended to run using systemd timers, or as a Docker container.
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import feedparser
|
import feedparser
|
||||||
|
|
@ -53,7 +53,6 @@ def get_description(feed, length=250, min_length=150, addons=None):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
length -= 1
|
length -= 1
|
||||||
desc = temporary_string[:length]
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
temporary_string = str(feed["description"])
|
temporary_string = str(feed["description"])
|
||||||
temporary_string = html_filter.sub("", temporary_string)
|
temporary_string = html_filter.sub("", temporary_string)
|
||||||
|
|
@ -62,7 +61,10 @@ def get_description(feed, length=250, min_length=150, addons=None):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
length -= 1
|
length -= 1
|
||||||
desc = temporary_string[:length]
|
|
||||||
|
desc = temporary_string[:length]
|
||||||
|
if addons is not None:
|
||||||
|
desc = desc + str(addons)
|
||||||
return desc
|
return desc
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -101,7 +103,7 @@ def setupPaths():
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
filename=str(log_dir + log_file_path),
|
filename=str(log_dir + log_file_path),
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
level=logging.INFO,
|
level=logging.WARNING,
|
||||||
datefmt="%m/%d/%Y %H:%M:%S",
|
datefmt="%m/%d/%Y %H:%M:%S",
|
||||||
format="%(asctime)s: %(levelname)s: %(message)s",
|
format="%(asctime)s: %(levelname)s: %(message)s",
|
||||||
)
|
)
|
||||||
|
|
@ -136,7 +138,7 @@ def main():
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
if bad_time is True:
|
if bad_time is True:
|
||||||
logger.warning(
|
logger.info(
|
||||||
"Feed %s doesn't supply a published time, using updated time instead",
|
"Feed %s doesn't supply a published time, using updated time instead",
|
||||||
hook["name"],
|
hook["name"],
|
||||||
)
|
)
|
||||||
|
|
@ -210,9 +212,10 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if os.environ["INVOCATION_ID"]:
|
try:
|
||||||
main()
|
if os.environ["INVOCATION_ID"]:
|
||||||
else:
|
main()
|
||||||
|
except KeyError:
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue