Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edent/tweet2embed
Convert a public Tweet into embedded semantic HTML
https://github.com/edent/tweet2embed
html python semantic-web twitter twitter-api
Last synced: 5 days ago
JSON representation
Convert a public Tweet into embedded semantic HTML
- Host: GitHub
- URL: https://github.com/edent/tweet2embed
- Owner: edent
- License: mit
- Created: 2024-08-08T07:24:29.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-10-27T22:20:09.000Z (about 2 months ago)
- Last Synced: 2024-12-14T19:30:44.910Z (8 days ago)
- Topics: html, python, semantic-web, twitter, twitter-api
- Language: Python
- Homepage:
- Size: 70.3 KB
- Stars: 159
- Watchers: 5
- Forks: 7
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tweet2Embed
Convert a public Tweet into either:
* Image & alt text
* Semantic HTML and CSSUses Selenium's Webdriver to launch a Firefox or Chrome instance and takes a screenshot. Uses the Twitter embed API to get a copy of the text and any alt text. An HTML representation is copied to the clipboard.
## Features
* 🗣 Avatars inlined as WebP
* 📸 All attached photos inlined
* 🎥 Video poster inline, to original mp4
* 🔗 Hyperlinks don't use t.co
* #️⃣ Hashtags & @ mentions linked
* 🔄 Includes reply threads & quote Tweets
* 🕰 Semantic time
* 🔍 Schema.org metadata
* 🖼 Cards
* 📊 Polls
* ♥ , 🔁 & 🗨 counts
* 📖 Autosubmit the Tweet to Archive.org## Usage
### tweet2html
* `python tweet2html.py 123` will get the Tweet with ID 123, create an embedded HTML, and copy it to the clipboard.
* `--thread` to get a parent or quote tweet
* `--css` if you want the CSS as well
* `--pretty` for pretty-printed HTML
* `--save` save the HTML to a file
* `--schema` adds Schema.org metadata#### Typical Output
Run `python tweet2html.py -mtp 671919410630819840` and receive:
```html
The Beatles or The Rolling Stones?
The Beatles: (28,857)
28857
The Rolling Stones: (9,074)
9074
❤️ 113
💬 38
🔁 0
```## tweet2img
* `python tweet2img.py 123` will get the Tweet with ID 123, save a WebP screenshot, and print out the alt text.
* `python tweet2img.py 123 --thread` as above, but will include the parent Tweet if this is a reply.
* Screenshot and alt text are saved in the `output` directory.
* Clipboard receives a copy of the HTML - including data-encoded image - ready to paste in.
* ``## Useful Examples
* `1432768058028875791` Video
* `1095659600420966400` Reply - parent has image
* `909106648928718848` Multiple images
* `1560621791470448642` Quote Tweet
* `670060095972245504` Poll
* `83659275024601088` Deleted Tweet
* `1131218926493413377` Summary Card
* `1485588404037648389` Reply to a quoted Tweet## Known bugs:
* Fractional Scaling may produce slightly fuzzy images (Wayland related?)
* On tweet2img, the alt text contains t.co URls rather than the expanded ones (could use entities?)
* Only some Twitter Cards are rendered in HTML (are there more?)
* No Dark Mode (overkill?)
* Many other things (probably?)