|
#!/usr/bin/env python |
|
# coding: utf-8 |
|
|
|
# Set banner headings to your Trello Series board automatically |
|
|
|
# You'll need to install two Python packages, available with pip: |
|
# * [py-trello](https://github.com/sarumont/py-trello) |
|
# * [tvdb_api](https://github.com/dbr/tvdb_api) |
|
|
|
from trello import TrelloClient |
|
from tvdb_api import Tvdb |
|
|
|
|
|
# First, get your api keys and authorize your user: |
|
# * `api_key` and `api_secret` are listed in this [Trello page](https://trello.com/app-key) |
|
# * `token` and `token_secret` must be retrieved for your user via OAuth. |
|
# Read [here](https://github.com/sarumont/py-trello#getting-your-trello-oauth-token) |
|
# |
|
# Last, specify the name of your series board. This script assumes that your cards are named |
|
# like this: `TV Series title S01E02` or `Upcoming series S01`. I mean, it will split the last |
|
# *word* out of the name and probably won't work if you don't follow my convention. |
|
|
|
api_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
|
api_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
|
token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
|
token_secret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" |
|
series_board_name = 'Series' |
|
|
|
############################################################################################## |
|
# Now, the actual code. |
|
client = TrelloClient(api_key, api_secret, token, token_secret) |
|
|
|
series = [b for b in client.list_boards() if b.name.decode('utf-8') == series_board_name][0] |
|
cards = series.all_cards() |
|
names = [c.name.decode('utf-8') for c in cards] |
|
|
|
tvdb = Tvdb(banners=True) |
|
results = [tvdb.search(' '.join(n.split()[:-1]))[0] for n in names] |
|
banners = ["http://thetvdb.com/banners/{}".format(r['banner']) for r in results] |
|
|
|
for card, banner in zip(cards, banners): |
|
card.attach(url=banner) |
|
|
|
|
|
# Final result: |
|
# |
|
#  |