Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

README

        

# Tweet2Embed

Convert a public Tweet into either:

* Image & alt text
* Semantic HTML and CSS

Uses 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






polls

@polls





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.
* `Screenshot from Twitter. 2022-08-19T13:36:44.000Z. Description.`

## 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?)