Selaa lähdekoodia

Document config re toot and alt-text templates

Fix template behavior when comment is `None`
(not relevant in our use case, but may be important one day).

`example.json` now contains a single image
(reference for available template fields).
master
The Dod 2 päivää sitten
vanhempi
commit
39aa69d85b
4 muutettua tiedostoa jossa 6 lisäystä ja 10354 poistoa
  1. 2
    0
      bloomscroller.py
  2. 3
    0
      config.py
  3. 1
    5138
      example.json
  4. 0
    5216
      example2.json

+ 2
- 0
bloomscroller.py Näytä tiedosto

@@ -23,6 +23,8 @@ def toot_next_image():
23 23
     mastodon = Mastodon(access_token="secrets.txt")
24 24
     image = get_next_image(get_images(config.ALBUM_API), get_previous_id())
25 25
     if image:
26
+        if image['comment'] is None:
27
+            image['comment'] = ""  # Better not mess up templates when no comment.
26 28
         media = mastodon.media_post(
27 29
             requests.get(
28 30
                 image["derivatives"][config.MEDIA_SIZE]["url"]).content,

+ 3
- 0
config.py Näytä tiedosto

@@ -5,8 +5,11 @@ APP_INSTANCE_URL = "https://tooot.im"
5 5
 
6 6
 ALBUM_API = "https://photos.nandn.org.il/piwigo/ws.php?format=json&method=pwg.categories.getImages&cat_id=21&per_page=529"
7 7
 
8
+# Both templates can use image fields like {name} and {comment} (see example.json)
9
+# I don't need it in my use case, but go ahead
8 10
 TOOT_TEMPLATE = "#Bloomscrolling"
9 11
 ALT_TEXT_TEMPLATE = "Flowers from n&n's garden arranged in a vase.\nPhotographed at {date_creation}."
12
+
10 13
 TOOT_LANGUAGE = "en"
11 14
 TOOT_VISIBILITY = "public"
12 15
 MEDIA_SIZE = "4xlarge"

+ 1
- 5138
example.json
File diff suppressed because it is too large
Näytä tiedosto


+ 0
- 5216
example2.json
File diff suppressed because it is too large
Näytä tiedosto


Loading…
Peruuta
Tallenna