Skip to content

Instantly share code, notes, and snippets.

@jaimergp
Created February 6, 2016 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaimergp/3845d1ac98f9c67e7f5b to your computer and use it in GitHub Desktop.
Save jaimergp/3845d1ac98f9c67e7f5b to your computer and use it in GitHub Desktop.
Trello Series board banners with TVDB
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/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:
#
# ![Imgur](http://i.imgur.com/ytWpxVX.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment