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.AnnouncerFAWM 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, 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(song_id: int, 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.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], consumer_key: str, consumer_secret: str, oauth_token: str, oauth_secret: str)[source]¶ Bases:
nefelibata.announcers.AnnouncerA 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.wtsocial module¶
Bases:
nefelibata.announcers.AnnouncerPublish the summary of a post to WT.Social.
Collect responses to a given post.
Perform login and return HTML page.
Extract CSRF token from a page.
The token is stored in a meta tag:
<meta name=”csrf-token” content=”PZ2AHyOSbUSRjaMNFLISKXPdghG8NPn0TZnjtteJ”>
Generate a standard reply from a comment.
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(post: nefelibata.post.Post) → None[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.Response(**kwargs)¶ Bases:
dict-
color¶
-
comment¶
-
id¶
-
source¶
-
timestamp¶
-
url¶
-
user¶
-
-
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]¶