Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/mastotron/mastotron

A different interface to mastodon, and other experiments in social media
https://github.com/mastotron/mastotron

gui macos mastodon python social-media social-network

Last synced: 2 months ago
JSON representation

A different interface to mastodon, and other experiments in social media

Awesome Lists containing this project

README

        

{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# mastotron\n",
"\n",
"Experiments in algorithmifying mastodon"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"

\n",
"

\n",
"[email protected] (382 👥) reposted at 12/24/2022 at 10:23:22:\n",
"

\n",
"\n",
"\n",
"
\n",
"

\n",
"[email protected] (379 👥) wrote on 12/24/2022 at 08:54:51:\n",
"

\n",
"\n",
"

RT @luismbat@birbsite


Who would have thought that adding a Sierpinski Triangle Fractal as musical notes would actually sound good!😅

\n",
"\n",
"\n",
"\n",
"

\n",
"3 🗣\n",
"  |   \n",
"25 🔁\n",
"  |  \n",
"0 💙\n",
"  |  \n",
"Post ID: 109567809382202427\n",
"

\n",
"\n",
"\n",
"
\n",
"\n",
"
\n",
"\n",
"
\n"
],
"text/plain": [
"Post(id=109568157841720925)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# load the class\n",
"from mastotron import Mastotron, Post\n",
"\n",
"# instantiate; will guide through auth\n",
"tron = Mastotron()\n",
"\n",
"# get latest post\n",
"post = tron.latest_post()\n",
"post"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"
\n",
"

\n",
"[email protected] (1,157 👥) wrote on 12/24/2022 at 02:11:04:\n",
"

\n",
"\n",
"

EXTREMELY RARE footage of the elusive box jellyfish Chirodectes. Larger than a soccer ball, this jelly is a true ocean mystery, and this video is one of the only in existence, filmed off the coast of Papua New Guinea in 2021.
📽️Scuba Ventures Kavieng bit.ly/3FE29tL

\n",
"\n",
"\n",
"\n",
"

\n",
"11 🗣\n",
"  |   \n",
"77 🔁\n",
"  |  \n",
"4 💙\n",
"  |  \n",
"Post ID: 109566222383974657\n",
"

\n",
"\n",
"\n",
"
\n"
],
"text/plain": [
"Post(id=109566222383974657)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get a post by id on your server\n",
"post = Post(id=109566222383974657)\n",
"post"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"
\n",
"

\n",
"accommodatingly (287 👥) reposted at 12/23/2022 at 23:51:23:\n",
"

\n",
"\n",
"\n",
"
\n",
"

\n",
"[email protected] (1,367 👥) wrote on 12/23/2022 at 14:42:00:\n",
"

\n",
"\n",
"

Thinking of all the queer folks who have to spend the holidays with abusive, unaccepting, unsupportive, or “well meaning” but careless relatives. It’s an especially dark time for many who can’t escape those situations because they’re minors, financially dependent, or under emotional pressure to attend.


If you’re out there, struggling, and need a friendly voice, feel free to drop a DM. I’m happy to be your trans goth aunt for a bit.


#queer #trans #holidays #support

\n",
"\n",
"\n",
"\n",
"

\n",
"12 🗣\n",
"  |   \n",
"60 🔁\n",
"  |  \n",
"4 💙\n",
"  |  \n",
"Post ID: 109563512620764058\n",
"

\n",
"\n",
"\n",
"
\n",
"\n",
"
\n",
"\n",
"
\n"
],
"text/plain": [
"Post(id=109565672404848243)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# These will show reposts/boosts:\n",
"post = Post(id=109565672404848243)\n",
"post"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(Post(id=109565672404848243), Post(id=109563512620764058))"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# the post and boosted post\n",
"post, post.is_boost_of"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"
\n",
"

\n",
"heuser (235 👥) wrote on 12/23/2022 at 19:00:50:\n",
"

\n",
"\n",
"

Unexpected challenge: there are very few likes on tweets in my mastodon timeline. (step that up pls everyone thx.) So it's hard to sort the tweets using that metric.

\n",
"\n",
"\n",
"\n",
"

\n",
"1 🗣\n",
"  |   \n",
"0 🔁\n",
"  |  \n",
"2 💙\n",
"  |  \n",
"Post ID: 109564529870067074\n",
"

\n",
"\n",
"

... in reply to:

\n",
"
\n",
"

\n",
"heuser (235 👥) wrote on 12/23/2022 at 18:42:58:\n",
"

\n",
"\n",
"

Experimenting with making an "algorithm" to sort a user's feed using python and mastodon.py. This tweet was sent from a jupyter notebook.

\n",
"\n",
"\n",
"\n",
"

\n",
"1 🗣\n",
"  |   \n",
"1 🔁\n",
"  |  \n",
"3 💙\n",
"  |  \n",
"Post ID: 109564459673004810\n",
"

\n",
"\n",
"\n",
"
\n",
"
\n",
"
\n"
],
"text/plain": [
"Post(id=109564529870067074)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# And replies\n",
"post = Post(id=109564529870067074)\n",
"post"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(Post(id=109564529870067074), Post(id=109564459673004810))"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# the replied-to post\n",
"post, post.is_reply_to"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# these can be chained\n",
"Post(id=109564658606466762).is_reply_to.is_reply_to.is_reply_to.id == post.id"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Scoring posts"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Simple': 1.7320508075688774,\n",
" 'ExtendedSimple': 1.8171205928321397,\n",
" 'SimpleWeighted': 0.11274690420042434,\n",
" 'ExtendedSimpleWeighted': 0.11828447555082267,\n",
" 'All': 0.4526308886948211}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get scores for a post \n",
"# (adapted from https://github.com/hodgesmr/mastodon_digest)\n",
"post.scores()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"
\n",
"

\n",
"ecourtem (346 👥) reposted at 12/23/2022 at 14:53:21:\n",
"

\n",
"\n",
"\n",
"
\n",
"

\n",
"[email protected] (5,061 👥) wrote on 12/23/2022 at 02:36:55:\n",
"

\n",
"\n",
"

Every gen X person read a terrifying Stephen King book when they were 9

\n",
"\n",
"\n",
"\n",
"

\n",
"55 🗣\n",
"  |   \n",
"33 🔁\n",
"  |  \n",
"1 💙\n",
"  |  \n",
"Post ID: 109560661039545409\n",
"

\n",
"\n",
"\n",
"
\n",
"\n",
"
\n",
"\n",
"
\n"
],
"text/plain": [
"Post(id=109563556725970365)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Get top posts by score\n",
"top_posts = sorted(\n",
" tron.latest_posts(max_posts=100),\n",
" key=lambda post: -post.score()\n",
")\n",
"\n",
"# top post by engagement\n",
"top_posts[0]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.7"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "3fd48361b044f528a2157a6d50412eb847c334dc1d3abbb213ba1b507b3cd253"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}