nefelibata.announcers package

Submodules

nefelibata.announcers.fawm module

class nefelibata.announcers.fawm.FAWMAnnouncer(root: pathlib.Path, config: Dict[str, Any], username: str, password: str)[source]

Bases: nefelibata.announcers.Announcer

FAWM Announcer

FAWM (February Album Writing Month) is a website where every year thousands of people participate in a challenge to write 14 songs in 28 days during the month of February.

Every year the website reboots, and comments are lost, making it particularly suited for Nefelibata.

In order to publish a song, the post should be structured like this:

# Liner Notes

<notes about the song>

# Lyrics

<pre>

<lyrics go here>

</pre>

Everything else is ignored, so you can add an audio player outside of those sections.

You also need to have an MP3 in your post directory, if you want to have it published as a demo.

announce(post: nefelibata.post.Post)str[source]

Publish the song to FAWM.

collect(post: nefelibata.post.Post) → List[nefelibata.announcers.Response][source]

Collect responses.

id = 'fawm'
name = 'FAWM'
url_header = 'fawm-url'
nefelibata.announcers.fawm.extract_params(post: nefelibata.post.Post, root: pathlib.Path, config: Dict[str, Any]) → Dict[str, Any][source]

Extract params from a standard FAWM post.

nefelibata.announcers.fawm.get_comments_from_fawm_page(url: str, username: str, password: str) → List[nefelibata.announcers.Response][source]

Extract comments from a given FAWM page.

nefelibata.announcers.fawm.get_response_from_li(url: str, el: bs4.element.Tag)nefelibata.announcers.Response[source]

Generate a standard response from a <li> element in the FAWM song page.

nefelibata.announcers.fiftyninety module

class nefelibata.announcers.fiftyninety.FiftyNinetyAnnouncer(root: pathlib.Path, config: Dict[str, Any], username: str, password: str)[source]

Bases: nefelibata.announcers.Announcer

FiftyNinety Announcer

FiftyNinety is a website where every year of people participate in a challenge to write 50 songs in 90 days during the northern hemisphere summer.

Every year the website reboots, and comments are lost, making it particularly suited for Nefelibata.

In order to publish a song, the post should be structured like this:

# Liner Notes

<notes about the song>

# Lyrics

<pre>

<lyrics go here>

</pre>

Lyrics are optional. Everything else is ignored, so you can add an audio player outside of those sections.

You also need to have an MP3 in your post directory, if you want to have it published as a demo.

announce(post: nefelibata.post.Post)str[source]

Publish the song to FiftyNinety.

collect(post: nefelibata.post.Post) → List[nefelibata.announcers.Response][source]

Collect responses.

id = 'fiftyninety'
name = 'FiftyNinety'
url_header = 'fiftyninety-url'
nefelibata.announcers.fiftyninety.extract_params(session: requests.sessions.Session, post: nefelibata.post.Post, root: pathlib.Path, config: Dict[str, Any]) → Dict[str, Any][source]

Extract params from a standard FiftyNinety post.

nefelibata.announcers.fiftyninety.get_comments_from_fiftyninety_page(session: requests.sessions.Session, url: str, username: str, password: str) → List[nefelibata.announcers.Response][source]

Extract comments from a given FiftyNinety page.

nefelibata.announcers.fiftyninety.get_fid(session, options: str, demo: str)str[source]
nefelibata.announcers.fiftyninety.get_form_params_from_input(html: str, form_id: str) → Tuple[str, str][source]
nefelibata.announcers.fiftyninety.get_session(username: str, password: str) → requests.sessions.Session[source]
nefelibata.announcers.fiftyninety.parse_fuzzy_timestamp(timestamp: str)datetime.datetime[source]

Parse fuzzy timestamps.

FiftyNinety annotates comments with relative timestamps:

  • 0 sec

  • 3 min 50 sec

  • 20 hours 38 min

  • 1 hour 52 min

  • 1 day 16 hours

nefelibata.announcers.mastodon module

class nefelibata.announcers.mastodon.MastodonAnnouncer(root: pathlib.Path, config: Dict[str, Any], access_token: str, base_url: str)[source]

Bases: nefelibata.announcers.Announcer

announce(post: nefelibata.post.Post)str[source]

Publish a post in a service and return the URL.

collect(post: nefelibata.post.Post) → List[nefelibata.announcers.Response][source]

Collect responses.

id = 'mastodon'
name = 'Mastodon'
url_header = 'mastodon-url'
nefelibata.announcers.mastodon.get_response_from_toot(toot: mastodon.Mastodon.AttribAccessDict)nefelibata.announcers.Response[source]

nefelibata.announcers.medium module

class nefelibata.announcers.medium.MediumAnnouncer(root: pathlib.Path, config: Dict[str, Any], access_token: str, publish_status: str)[source]

Bases: nefelibata.announcers.Announcer

announce(post: nefelibata.post.Post)str[source]

Publish a post in a service and return the URL.

collect(post: nefelibata.post.Post) → List[nefelibata.announcers.Response][source]

Collect responses.

id = 'medium'
name = 'Medium'
url_header = 'medium-url'
nefelibata.announcers.medium.get_responses_from_payload(payload: Dict[str, Any]) → List[nefelibata.announcers.Response][source]

nefelibata.announcers.twitter module

class nefelibata.announcers.twitter.TwitterAnnouncer(root: pathlib.Path, config: Dict[str, Any], handle: str, consumer_key: str, consumer_secret: str, oauth_token: str, oauth_secret: str)[source]

Bases: nefelibata.announcers.Announcer

A Twitter announcer/collector.

The configuration in nefelibata.yaml should look like this:

twitter:

consumer_key: XXX consumer_secret: XXX oauth_token: XXX oauth_secret: XXX

In order to create consumer_key and consumer_secret you must visit https://dev.twitter.com/apps/new and register a new application. Then you should run the following script to get oauth_token and oauth_secret:

import os from twitter import *

CONSUMER_KEY = “XXX” CONSUMER_SECRET = “XXX” oauth_dance(“My App Name”, CONSUMER_KEY, CONSUMER_SECRET, “secret.txt”)

After running the script and following the instructions oauth_token and oauth_secret will be stored in secret.txt.

announce(post: nefelibata.post.Post)str[source]

Publish the summary of a post to Twitter.

collect(post: nefelibata.post.Post) → List[nefelibata.announcers.Response][source]

Collect responses to a given tweet.

Amazingly there’s no support in the API to fetch all replies to a given tweet id, so we need to fetch all mentions and see which of them are a reply.

id = 'twitter'
name = 'Twitter'
url_header = 'twitter-url'
nefelibata.announcers.twitter.get_response_from_mention(tweet: Dict[str, Any])nefelibata.announcers.Response[source]

Generate a standard reply from a Tweet.

nefelibata.announcers.webmention module

class nefelibata.announcers.webmention.WebmentionAnnouncer(root: pathlib.Path, config: Dict[str, Any], endpoint: str)[source]

Bases: nefelibata.announcers.Announcer

announce(post: nefelibata.post.Post)str[source]

Publish a post in a service and return the URL.

collect(post: nefelibata.post.Post) → List[nefelibata.announcers.Response][source]

Collect responses.

id = 'webmention'
name = 'Webmention'
should_announce(post: nefelibata.post.Post)bool[source]
url_header = 'webmention-url'
nefelibata.announcers.webmention.get_response_from_child(child: Dict[str, Any], target: str)nefelibata.announcers.Response[source]
nefelibata.announcers.webmention.get_webmention_endpoint(url) → Optional[str][source]
nefelibata.announcers.webmention.summarize(text: str, target: Optional[str] = None)str[source]

nefelibata.announcers.wtsocial module

class nefelibata.announcers.wtsocial.WTSocialAnnouncer(root: pathlib.Path, config: Dict[str, Any], email: str, password: str)[source]

Bases: nefelibata.announcers.Announcer

announce(post: nefelibata.post.Post) → Optional[str][source]

Publish the summary of a post to WT.Social.

collect(post: nefelibata.post.Post) → List[nefelibata.announcers.Response][source]

Collect responses to a given post.

id = 'wtsocial'
name = 'WT.Social'
url_header = 'wtsocial-url'
nefelibata.announcers.wtsocial.do_login(session: requests.sessions.Session, email: str, password: str)str[source]

Perform login and return HTML page.

nefelibata.announcers.wtsocial.get_csrf_token(html: str) → Optional[str][source]

Extract CSRF token from a page.

The token is stored in a meta tag:

<meta name=”csrf-token” content=”PZ2AHyOSbUSRjaMNFLISKXPdghG8NPn0TZnjtteJ”>

nefelibata.announcers.wtsocial.get_response_from_comment(comment: Dict[str, Any])nefelibata.announcers.Response[source]

Generate a standard reply from a comment.

nefelibata.announcers.wtsocial.get_user_image(username: str) → Optional[str][source]

Return URL of the profile picture of a given user.

Module contents

class nefelibata.announcers.Announcer(root: pathlib.Path, config: Dict[str, Any], *args: Any, **kwargs: Any)[source]

Bases: object

announce(post: nefelibata.post.Post) → Optional[str][source]

Publish a post in a service and return the URL.

collect(post: nefelibata.post.Post) → List[nefelibata.announcers.Response][source]

Collect responses.

id = 'base'
match(post: nefelibata.post.Post)[source]
name = 'Base'
should_announce(post: nefelibata.post.Post)bool[source]

Update links.json with link to where the post is announced.

update_replies(post: nefelibata.post.Post)None[source]

Update replies.json with new replies, if any.

url_header = 'base-url'
class nefelibata.announcers.Comment(**kwargs)

Bases: dict

html: str
summary: str
text: str
url: str
class nefelibata.announcers.Response(**kwargs)

Bases: dict

color: str
comment: nefelibata.announcers.Comment
id: str
source: str
timestamp: str
url: str
user: nefelibata.announcers.User
class nefelibata.announcers.User(**kwargs)

Bases: dict

description: str
image: str
name: str
url: str
nefelibata.announcers.fetch_hcard(user: nefelibata.announcers.User)nefelibata.announcers.User[source]
nefelibata.announcers.get_announcers(root: pathlib.Path, config: Dict[str, Any]) → List[nefelibata.announcers.Announcer][source]
nefelibata.announcers.get_post_announcers(config: Dict[str, Any], post: nefelibata.post.Post) → Set[str][source]