Compare commits

...

13 commits
0.14 ... master

Author SHA1 Message Date
MassiveBox 9782f0321f Add docker support
- Allow setup script to get credentials from flags
- Add Dockerfile and docker_entrypoint
- Edit README for forked version
2022-10-23 22:09:20 +02:00
Carl Chenet 9ae33644e5 bump version and update version 2021-03-26 18:22:57 +01:00
Carl Chenet 475bdae925 add __init__ for scripts dir. fixes #62 2021-03-26 18:08:39 +01:00
Carl Chenet 02dc5f7887 add 0.16 description 2020-12-09 01:33:49 +01:00
Carl Chenet a8958f914b bump version 2020-12-09 01:29:25 +01:00
Carl Chenet 72100f4cac register_feed2toot_app: --name, --user-credentials-file and client-credentials-file CLI options and documentation 2020-12-09 01:23:47 +01:00
Carl Chenet 38f6ddb355 update changelog 2020-12-07 20:36:43 +01:00
Carl Chenet 22cf7b4208 update author email and copyright 2020-12-07 20:33:30 +01:00
Carl Chenet 32fd92e9e2 bump to 0.15 2020-12-07 20:13:39 +01:00
Carl Chenet 9b0e31b0e9 Merge branch 'cmiksche-master-patch-36978' into 'master'
fix issue when only uri_list and no uri is configured

Closes #58

See merge request chaica/feed2toot!16
2020-12-07 15:23:45 +00:00
Christoph Miksche 45bb623f86 fix issue when only uri_list and no uri is configured
Fixes #58
2020-11-29 16:47:14 +00:00
Carl Chenet 990da8796c Merge branch 'patch-1' into 'master'
Fix a spelling mistake and word choice in documentation

See merge request chaica/feed2toot!15
2020-06-25 07:34:12 +00:00
Procyonid cfd3f17162 Fixed minor writing errors. 2020-06-24 17:33:03 +00:00
47 changed files with 264 additions and 142 deletions

3
.gitignore vendored
View file

@ -1,6 +1,7 @@
docs/build/
__pycache__
feedlist
data
*.swp
*.pyc
*.db
@ -8,3 +9,5 @@ feedlist
*.txt
*.bck
*.png
*.yml
.env

View file

@ -1,5 +1,5 @@
Antoine Beaupré <anarcat@debian.org>
Carl Chenet <chaica@ohmytux.com>
Carl Chenet <carl.chenet@ohmytux.com>
Alexis Metaireau <alexis@notmyidea.org>
The Dod <https://social.weho.st/@thedod>
Matthias Henze

View file

@ -1,3 +1,22 @@
## [0.17] - 2021-03-26
### Changed
- fix install bug while installing from sources
- bump changelog
## [0.16] - 2020-12-09
### Added
- scripts/register_feed2toot_app: --client-credentials-file option to change the filename in which the client credentials are stored
- scripts/register_feed2toot_app: --user-credentials-file option to change the filename in which the client credentials are stored
- scripts/register_feed2toot_app: --name to change the Mastodon app name
## [0.15] - 2020-12-07
### Changed
- maintenance version
- fix bug while using uri_list parameter alone following feedparser upgrade
- update copyrigth
- update author email
## [0.14] - 2019-12-31
### Added
- support for line breaks in toots

13
Dockerfile Normal file
View file

@ -0,0 +1,13 @@
FROM python:3.7-bullseye
ADD . /app
WORKDIR /app
RUN python3 setup.py install; \
chmod +x docker_entrypoint.sh; \
mkdir -p /data /root/.config; \
rm -rf docke.yml
WORKDIR /data
CMD ["/app/docker_entrypoint.sh"]

View file

@ -1,65 +1,46 @@
# Feed2Toot Docker
Feed2Toot Docker is a fork of [chaica/feed2toot](https://gitlab.com/chaica/feed2toot) that allows for simple deployment over Docker. In the future I'll try to add other useful features.
### Usage
With Docker Compose:
```yaml
version: '3'
services:
feed2toot:
image: gitea.massivebox.net/massivebox/feed2toot-docker:latest
environment:
- USERNAME=sampleusername@sampleinstance.url
- PASSWORD=samplepassword
- INSTANCE=https://sampleinstance.url
restart: always
volumes:
- ./data:/data
```
Insert your full username (including the part with your homeserver's address), password and instance URL where required.
You also need to create a working `feed2toot.ini` in the `./data` folder. See the [upstream docs](`https://feed2toot.readthedocs.io/en/latest/configure.html#create-feed2toot-configuration`) for the guide.
After the first successful run, you can remove the entire `environment` block if you want, however, if you delete and re-create the container, you will need to put it back.
### Support
Don't ask the upstream developers for help, if something is broken it's more likely that it is my fault.
You can get support by opening an [issue](https://gitea.massivebox.net/massivebox/feed2toot-docker/issues), or by [contacting me](https://massivebox.net/contact.html), or in the [Matrix support room](https://matrix.to/#/#support:massivebox.net).
### Feed2toot
Feed2toot automatically parses rss feeds, identifies new posts and posts them on the [Mastodon](https://mastodon.social) social network.
For the full documentation, [read it online](https://feed2toot.readthedocs.io/en/latest/).
If you would like, you can [support the development of this project on Liberapay](https://liberapay.com/carlchenet/).
Alternatively you can donate cryptocurrencies:
The following links and addresses are the upstream developers'. I don't want donations for this project, but I encourage you to donate to them.
- [Liberapay](https://liberapay.com/carlchenet/)
- BTC: 1AW12Zw93rx4NzWn5evcG7RNNEM2RSLmAC
- XMR: 43GGv8KzVhxehv832FWPTF7FSVuWjuBarFd17QP163uxMaFyoqwmDf1aiRtS5jWgCiRsi73yqedNJJ6V1La2joznKHGAhDi
### Quick Install
* Install Feed2toot from PyPI
# pip3 install feed2toot
* Install Feed2toot from sources
*(see the installation guide for full details)
[Installation Guide](http://feed2toot.readthedocs.io/en/latest/install.html)*
# tar zxvf feed2toot-0.14.tar.gz
# cd feed2toot
# python3 setup.py install
# # or
# python3 setup.py install --install-scripts=/usr/bin
### Create the authorization for the Feed2toot app
* Just launch the following command::
$ register_feed2toot_app
### Use Feed2toot
* Create or modify feed2toot.ini file in order to configure feed2toot:
[mastodon]
instance_url=https://mastodon.social
user_credentials=feed2toot_usercred.txt
client_credentials=feed2toot_clientcred.txt
; Default visibility is public, but you can override it:
; toot_visibility=unlisted
[cache]
cachefile=cache.db
[rss]
uri=https://www.journalduhacker.net/rss
toot={title} {link}
[hashtaglist]
several_words_hashtags_list=hashtags.txt
* Launch Feed2toot
$ feed2toot -c /path/to/feed2toot.ini
### Authors
* Carl Chenet <chaica@ohmytux.com>
* MassiveBox <massivebox@massivebox.net>
* Carl Chenet <carl.chenet@ohmytux.com>
* Antoine Beaupré <anarcat@debian.org>
* First developed by Todd Eddy

12
docker_entrypoint.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/bash
cd /data
if [[ ! -f "feed2toot_clientcred.txt" || ! -f "feed2toot_usercred.txt" ]]; then
register_feed2toot_app --instance $INSTANCE --username $USERNAME --password $PASSWORD
fi
while :; do
feed2toot -c ./feed2toot.ini
sleep 5m
done

View file

@ -1,4 +1,4 @@
Authors
=======
Carl Chenet <chaica@ohmytux.com>
Carl Chenet <carl.chenet@ohmytux.com>

View file

@ -31,6 +31,7 @@ import os
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosectionlabel'
]
# Add any paths that contain templates here, relative to this directory.
@ -47,16 +48,16 @@ master_doc = 'index'
# General information about the project.
project = 'feed2toot'
copyright = '2015-2019, Carl Chenet <chaica@ohmytux.com>'
copyright = '2015-2021, Carl Chenet <carl.chenet@ohmytux.com>'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '0.14'
version = '0.17'
# The full version, including alpha/beta/rc tags.
release = '0.14'
release = '0.17'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@ -200,7 +201,7 @@ latex_elements = {
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'feed2toot.tex', 'feed2toot Documentation',
'Carl Chenet \\textless{}chaica@ohmytux.com.org\\textgreater{}', 'manual'),
'Carl Chenet \\textless{}carl.chenet@ohmytux.com.org\\textgreater{}', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@ -230,7 +231,7 @@ latex_documents = [
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'feed2toot', 'feed2toot Documentation',
['Carl Chenet <chaica@ohmytux.com>'], 1)
['Carl Chenet <carl.chenet@ohmytux.com>'], 1)
]
# If true, show URL addresses after external links.
@ -244,7 +245,7 @@ man_pages = [
# dir menu entry, description, category)
texinfo_documents = [
('index', 'feed2toot', 'feed2toot Documentation',
'Carl Chenet <chaica@ohmytux.com>', 'feed2toot', 'One line description of project.',
'Carl Chenet <carl.chenet@ohmytux.com>', 'feed2toot', 'One line description of project.',
'Miscellaneous'),
]

View file

@ -1,23 +1,34 @@
Configure Feed2toot
===================
Create credentials for Mastodon
-------------------------------
As a prerequisite to use Feed2toot, you need to authorize a Mastodon app for your account.
Just use the script register_feed2toot_app to register the feed2toot app for your account.::
$ ./register_feed2toot_app
This app generates Mastodon app credentials needed by Feed2toot.
feed2toot_clientcred.txt and feed2toot_usercred.txt will be written in the current dir /home/chaica/progra/python/feed2toot.
One connection is initiated to create the app.
This script generates the Mastodon application credentials for Feed2toot.
feed2toot_clientcred.txt and feed2toot_usercred.txt will be written
in the current directory: /home/me/feed2toot.
WARNING: previous files with the same names will be overwritten.
A connection is also initiated to create the application.
Your password is *not* stored.
Mastodon instance URL (defaults to https://mastodon.social): https://framapiaf.org
Mastodon login: toto@titi.com
Mastodon password:
The app feed2toot was added to your Preferences=>Accounts=>Authorized apps page.
The file feed2toot_clientcred.txt and feed2toot_usercred.txt were created in the current directory.
Mastodon instance url (defaults to https://mastodon.social):
Mastodon login:chaica@ohmytux.com
Mastodon password:
The feed2toot app was added to your preferences=>authorized apps page
As described above, two files were created. See the :ref:`Use register_feed2toot_app` section for more options for register_feed2toot_app.
As described above, two files were created. You'll need them in the feed2toot configuration.
Create Feed2toot configuration
------------------------------
After using register_feed2toot_app, you'll need the credentials in the feed2toot configuration.
In order to configure Feed2toot, you need to create a feed2toot.ini file (or any name you prefer, finishing with the extension .ini) with the following parameters::
@ -88,7 +99,7 @@ For the [rss] section:
- {one field of the rss feed}_pattern: takes a string representing a pattern to match for a specified field of each rss entry of the rss feed, like title_pattern or summary_pattern.
- {one field of the rss feed}_pattern_case_sensitive: either the pattern matching for the specified field should be case sensitive or not. Default to true if not specified.
- no_uri_pattern_no_global_pattern: don't apply global pattern (see above) when no pattern-by-uri is defined in the uri_list. Allows to get all entries of a rss in the uri_list because no pattern is defined so we match them all. Defaults to false, meaning the global patterns will be tried on every rss in the uri_list NOT HAVING specific patterns and so ONLY entries from the specific uri in the uri_list matching the global patterns will be considered.
addtags: add the tags from the rss feed at the end of the toot. Defaults to true.
- addtags: add the tags from the rss feed at the end of the toot. Defaults to true.
- ignore_ssl: when the uri or uri_list contains an https url with an invalid certificate (e.g an expired one), feed2toot will be unable to get rss content. This option allows to bypass the ssl security to catch the rss content. Defaults to false.
For the [hashtaglist] section:
@ -143,8 +154,8 @@ Match specific patterns of rss feeds in the uri_list files
----------------------------------------------------------
You can use specific pattern matching for uri in the uri_list file to filter some of the rss entries of a rss feed. Lets modify the previous file::
https://www.journalduhacker.net/rss|title|hacker,psql
https://carlchenet.com/feed|title|gitlab
https://www.journalduhacker.net/rss|title|hacker,psql
https://carlchenet.com/feed|title|gitlab
Each line of this file starts with an uri, followed by a pipe (|), followed by the name of the available section to parse (see below), again followed by a pipe (|), followed by patterns, each pattern being separated from the other one by a semi-colon (,).
@ -166,9 +177,3 @@ In you rsslist.txt, just don't give anything else than the needed feed url to ge
The last line of the file above only has the url of a rss feed. All entries from this feed will be tooted.
How to display available sections of the rss feed
=================================================
Feed2toot offers the **--rss-sections** command line option to display the available section of the rss feed and exits::
$ feed2toot --rss-sections -c feed2toot.ini
The following sections are available in this RSS feed: ['title', 'comments', 'authors', 'link', 'author', 'summary', 'links', 'tags', id', 'author_detail', 'published'].

View file

@ -25,7 +25,7 @@ Alternatively, Setuptools may be installed to a user-local path::
* Untar the tarball and go to the source directory with the following commands::
$ tar zxvf feed2toot-0.14.tar.gz
$ tar zxvf feed2toot-0.17.tar.gz
$ cd feed2toot
* Next, to install Feed2toot on your computer, type the following command with the root user::

View file

@ -5,8 +5,8 @@ After the configuration of Feed2toot, just launch the following command::
$ feed2toot -c /path/to/feed2toot.ini
Run Feed2toot on a regular basis
=================================
Feed2toot should be launche on a regular basis in order to efficiently send your new RSS entries to Mastodon. It is quite easy to achieve with adding a line to your user crontab, as described below::
---------------------------------
Feed2toot should be launched on a regular basis in order to efficiently send your new RSS entries to Mastodon. It is quite easy to achieve by adding a line to your user crontab, as described below::
@hourly feed2toot -c /path/to/feed2toot.ini
@ -15,19 +15,19 @@ will execute feed2toot every hour. Or without the syntactic sugar in the global
0 * * * * johndoe feed2toot -c /path/to/feed2toot.ini
Test option
===========
-----------
In order to know what's going to be sent to Mastodon without actually doing it, use the **--dry-run** option::
$ feed2toot --dry-run -c /path/to/feed2toot.ini
Debug option
============
------------
In order to increase the verbosity of what's Feed2toot is doing, use the **--debug** option followed by the level of verbosity see [the the available different levels](https://docs.python.org/3/library/logging.html)::
$ feed2toot --debug -c /path/to/feed2toot.ini
Populate the cache file without posting tweets
==============================================
Populate the cache file without posting toots
---------------------------------------------
Starting from 0.8, Feed2toot offers the **--populate-cache** command line option to populate the cache file without posting to Mastodon::
$ feed2toot --populate-cache -c feed2toot.ini
@ -43,22 +43,55 @@ Starting from 0.8, Feed2toot offers the **--populate-cache** command line option
populating RSS entry https://www.journalduhacker.net/s/lqswmz
How to display available sections of the rss feed
=================================================
-------------------------------------------------
Starting from 0.8, Feed2toot offers the **--rss-sections** command line option to display the available section of the rss feed and exits::
$ feed2toot --rss-sections -c feed2toot.ini
The following sections are available in this RSS feed: ['title', 'comments', 'authors', 'link', 'author', 'summary', 'links', 'tags', id', 'author_detail', 'published'].
Using syslog
============
------------
Feed2toot is able to send its log to syslog. You can use it with the following command::
$ feed2toot --syslog=WARN -c /path/to/feed2toot.ini
Limit number of rss entries published at each execution
=======================================================
-------------------------------------------------------
If you want to limit the number of rss entries published at each execution, you can use the --limit CLI option.
$ feed2toot --limit 5 -c /path/to/feed2toot.ini
The number of posts to Mastodon will be at 5 posts top with this CLI option.
Use register_feed2toot_app
==========================
You need a Mastodon app associated to a user on the Mastodon instance. The script register_feed2toot_app will create an app for Feed2toot and upload it on the specified Mastodon instance.
Primary usage ::
$ register_feed2toot_app
Possible CLI options:
- use the **--client-credentials-file** option to change the filename in which the client credentials are stored (defaults to feed2toot_clientcred.txt)
- use the **--user-credentials-file** option to change the filename in which the user credentials are stored (defaults to feed2toot_usercred.txt)
- use the **--name** to change the Mastodon app name (defaults to feed2toot)
Example with full options and full output::
$ ./register_feed2toot_app --user-credentials-file f2tusercreds.txt --client-credentials-file f2tclientcreds.txt --name f2t
This script generates the Mastodon application credentials for Feed2toot.
f2tclientcreds.txt and f2tusercreds.txt will be written
in the current directory: /home/me/feed2toot/scripts.
WARNING: previous files with the same names will be overwritten.
A connection is also initiated to create the application.
Your password is *not* stored.
Mastodon instance URL (defaults to https://mastodon.social): https://framapiaf.org
Mastodon login: toto@titi.com
Mastodon password:
The app f2t was added to your preferences=>authorized apps page.
The file f2tclientcreds.txt and f2tusercreds.txt were created in the current directory.

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2017 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@ -24,7 +24,7 @@ import os
import os.path
import sys
__version__ = '0.14'
__version__ = '0.17'
class CliParse:
'''CliParse class'''

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@ -94,7 +94,11 @@ class ConfParse:
############
# uri option
############
options['rss_uri'], feed, feedname, options['nopatternurinoglobalpattern'] = parseuri(config, self.clioptions.rss_uri, feeds, ignore_ssl)
if config.has_option('rss', 'uri') or self.clioptions.rss_uri:
options['rss_uri'], feed, feedname, options['nopatternurinoglobalpattern'] = parseuri(config, self.clioptions.rss_uri, feeds, ignore_ssl)
else:
if config.has_option('rss', 'no_uri_pattern_no_global_pattern'):
options['nopatternurinoglobalpattern'] = config.getboolean('rss', 'no_uri_pattern_no_global_pattern')
###########################
# the cache section
###########################

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2017-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2017-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2017-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,5 +1,5 @@
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

15
scripts/__init__.py Normal file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or

View file

@ -1,7 +1,6 @@
#!/usr/bin/env python3
#!/usr/bin/env python3
# vim:ts=4:sw=4:ft=python:fileencoding=utf-8
# Copyright © 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright © 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@ -15,16 +14,42 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>
from argparse import ArgumentParser
from getpass import getpass
from os import getcwd
from os import linesep
from os import sep
from mastodon import Mastodon
from mastodon.Mastodon import MastodonIllegalArgumentError
import sys
print('\nThis script generates the Mastodon application credentials for Feed2toot.\nfeed2toot_clientcred.txt and feed2toot_usercred.txt will be written\nin the current directory: {cwd}.\nA connection is initiated to create the application.\nYour password is *not* stored.\n'.format(cwd=getcwd()))
__version__ = '0.2'
epilog = 'For more information: https://feed2toot.readthedocs.io'
description = 'Create a Mastodon app for Feed2toot'
parser = ArgumentParser(prog='register_feed2toot_app',
description=description,
epilog=epilog)
parser.add_argument('--version', action='version', version=__version__)
parser.add_argument('--client-credentials-file', dest='clientcredfile', help='the name of the client credentials for the Mastodon app', default='feed2toot_clientcred.txt')
parser.add_argument('--user-credentials-file', dest='usercredfile', help='the name of the user credentials for the Mastodon app', default='feed2toot_usercred.txt')
parser.add_argument('--name', help='the name of the Mastodon app', default='feed2toot')
parser.add_argument('--instance', help='the URL of the Mastodon instance')
parser.add_argument('--username', help='the username of your Mastodon account')
parser.add_argument('--password', help='the password of your Mastodon account')
opts = parser.parse_args()
clientcredfile=opts.clientcredfile
usercredfile=opts.usercredfile
headline = '{linesep}This script generates the Mastodon application credentials for Feed2toot.{linesep}{clientcredfile} and {usercredfile} will be written{linesep}in the current directory: {cwd}.{linesep}WARNING: previous files with the same names will be overwritten.{linesep}{linesep}A connection is also initiated to create the application.{linesep}Your password is *not* stored.{linesep}'.format(linesep=linesep, clientcredfile=clientcredfile, usercredfile=usercredfile, cwd=getcwd())
print(headline)
# get the instance
instance = input('Mastodon instance URL (defaults to https://mastodon.social): ')
instance = opts.instance
if not instance:
instance = input('Mastodon instance URL (defaults to https://mastodon.social): ')
if not instance:
instance = 'https://mastodon.social'
elif not instance.startswith('http'):
@ -32,34 +57,45 @@ elif not instance.startswith('http'):
# get the username
userok = False
quit_on_error = True
while not userok:
user = input('Mastodon login: ')
user = opts.username
if not user:
user = input('Mastodon login: ')
quit_on_error = False
if not user:
print('Your Mastodon username can not be empty.')
userok = False
elif '@' not in user or '.' not in user:
print('Your Mastodon username should be an email.')
userok = False
else:
userok = True
if not userok and quit_on_error:
exit()
# get the password
password = getpass(prompt='Mastodon password: ')
password = opts.password
if not password:
password = getpass(prompt='Mastodon password: ')
Mastodon.create_app(
'feed2toot',
opts.name,
api_base_url=instance,
to_file = '{cwd}/feed2toot_clientcred.txt'.format(cwd=getcwd())
to_file = '{cwd}{sep}{clientcredfile}'.format(cwd=getcwd(), sep=sep, clientcredfile=clientcredfile)
)
mastodon = Mastodon(client_id = '{cwd}/feed2toot_clientcred.txt'.format(cwd=getcwd()),
mastodon = Mastodon(client_id = '{cwd}{sep}{clientcredfile}'.format(cwd=getcwd(), sep=sep, clientcredfile=clientcredfile),
api_base_url=instance)
try:
mastodon.log_in(
user,
password,
to_file = '{cwd}/feed2toot_usercred.txt'.format(cwd=getcwd())
to_file = '{cwd}{sep}{usercredfile}'.format(cwd=getcwd(), sep=sep, usercredfile=usercredfile)
)
except MastodonIllegalArgumentError as err:
print(err)
sys.exit('\nI guess you entered a bad login or password.\n')
print('feed2toot was added to your preferences=>authorized apps page.')
sys.exit('{linesep}I guess you entered a bad login or password.{linesep}'.format(linesep=linesep))
summary = '{linesep}The app {appname} was added to your Preferences=>Accounts=>Authorized apps page.{linesep}The file {clientcredfile} and {usercredfile} were created in the current directory.{linesep}'.format(appname=opts.name,
linesep=linesep,
clientcredfile=clientcredfile,
usercredfile=usercredfile)
print(summary)
sys.exit(0)

View file

@ -1,4 +1,4 @@
# Copyright 2015-2019 Carl Chenet <carl.chenet@ohmytux.com>
# Copyright 2015-2021 Carl Chenet <carl.chenet@ohmytux.com>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@ -31,12 +31,12 @@ CLASSIFIERS = [
setup(
name='feed2toot',
version='0.14',
version='0.17',
license='GNU GPL v3',
description='Parse rss feeds and send new posts to Mastodon',
long_description='Parse rss feeds and send new posts to the Mastodon social network',
author = 'Carl Chenet',
author_email = 'chaica@ohmytux.com',
author_email = 'carl.chenet@ohmytux.com',
url = 'https://gitlab.com/chaica/feed2toot',
classifiers=CLASSIFIERS,
download_url='https://gitlab.com/chaica/feed2toot',