summaryrefslogtreecommitdiff
path: root/telegram.py
diff options
context:
space:
mode:
authorAndré Glüpker <git@wgmd.de>2024-05-01 09:52:09 +0200
committerAndré Glüpker <git@wgmd.de>2024-05-01 09:52:09 +0200
commit6152af251711b5b255c3a8167f8b1ff72e19ef6c (patch)
tree06c4201536a0afce40c1651c6fcb6f67ac6ef586 /telegram.py
parent664ceffea80fe3802b69a36e38bf924e8edf5fe3 (diff)
downloadrss-feeds-6152af251711b5b255c3a8167f8b1ff72e19ef6c.tar.gz
rss-feeds-6152af251711b5b255c3a8167f8b1ff72e19ef6c.tar.bz2
rss-feeds-6152af251711b5b255c3a8167f8b1ff72e19ef6c.zip
Remove telegram and twitter
Diffstat (limited to 'telegram.py')
-rwxr-xr-xtelegram.py68
1 files changed, 0 insertions, 68 deletions
diff --git a/telegram.py b/telegram.py
deleted file mode 100755
index d95ce34..0000000
--- a/telegram.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/usr/bin/env python3
-
-from urllib.request import urlopen, Request
-from datetime import datetime
-from bs4 import BeautifulSoup
-import sys
-
-from rss import _format_date
-
-
-def telegram(channel):
- url = "https://t.me/s/" + channel
- res = urlopen(Request(url))
- soup = BeautifulSoup(res, features="html.parser")
-
- # messages = soup.find_all('div', attrs={'class': 'tgme_widget_message_wrap'})
- messages = soup.find_all("div", attrs={"class": "tgme_widget_message_bubble"})
-
- for message in messages:
- date = message.find("time", attrs={"class": "time"})["datetime"]
- html = message.find("div", attrs={"class": "tgme_widget_message_text"})
- # preview = message.find('div', attrs={'class': 'tgme_widget_message_bubble'})
- link = message.find("a", attrs={"class": "tgme_widget_message_date"})
- title = html.text if html else "No text"
- description = str(message) # if preview else '?'
- link = link["href"]
- yield title, description, link, date
-
-
-def main(channel):
- url = "https://t.me/s/" + channel
-
- print(
- """<?xml version="1.0" encoding="UTF-8"?>
-<rss version="2.0">
- <channel>
- <title>Telegram: """
- + channel
- + """</title>
- <link>"""
- + url
- + """</link>
- <description>The latest entries of the telegram channel of """
- + channel
- + """</description>
- <lastBuildDate>"""
- + _format_date(datetime.now())
- + """</lastBuildDate>"""
- )
-
- for title, description, link, date in telegram(channel):
- print(" <item>")
- print(" <title><![CDATA[" + title + "]]></title>")
- print(" <link>" + link + "</link>")
- print(" <description><![CDATA[" + description + "]]></description>")
- print(" <pubDate>" + date + "</pubDate>")
- # print(' <media:content url="' + thumbnail + b'" type="image/jpeg" />')
- print(" </item>")
-
- print(" </channel>")
- print("</rss>")
-
-
-if __name__ == "__main__":
- if len(sys.argv) != 2:
- print("Usage:", sys.argv[0], "<telegram channel>")
- sys.exit(1)
- main(sys.argv[1])