An awesome README template to jumpstart your projects!
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
⚠️ Warning: This project has not been updated and tested for many years!⚠️
The last few months multiple lists became popular on Letterboxd in which the films were sorted by colour. An example: Arlo McLean's list 'color' Normally, sorting posters takes lots of time and multiple headaches. This code makes it easy. It sorts all the film a user has seen. It exports an .csv file that can be imported into letterboxd on the new list page .It also puts out an image of all the colours the code extracted from the poster. The last thing it exports is a plotly graph where all the colours are plotted by RGB value.
A new custom sorting method has been implemented: Using a K-means system to sort colours. This is an improvement over the old system. Colours are nw sorted into groups before begin sorted by value. List support has also been added. When running the script, the username can now be substituted for a lists url.
In the following example my personal Letterboxd account will be used: (Consider a follow) coencoensmeets. The code has only been tested on a windows 10 machine. First install APIs
- API installation
pip install -r requirements.txt
- Run the script
python LB_colour.py D:\\Home\\Data coencoensmeets -LPmI
The running of the script has been built up in the following way:
python LB_colour.py **Prefered directory** **Username** -**Options**
Directory: If the prefered directory can not be found, the current directory will be used. Username: This is the letterboxd username (the same username as is in the link to a profile) Lists links are now also supported. Options: With the many exports, an option has been added to disable a few. If no options are profived, only a list will be added. The options can be changes by added the letters. The options available:
-
L: This creates the letterboxd list with the posters sorted that can be imported.
-
I: Creates the image with the extracted colours sorted.
-
Pm: Creates the Plotly graph without lines.
-
Pl: Creates the Plotly graph with lines.
-
Check out the outputs The graph with lines:
Unfortunately, there are some apparent errors. Colour is interpreted in the brain and is influenced by many factors. The first issue is getting one single RGB value from a poster. What colour is leading in the image? Secondly, sorting colours is an impossible job to get correct and certainly for a machine. Alan Zucconi wrote a great article about it. (https://www.alanzucconi.com/2015/09/30/colour-sorting/)
Because of the limited acces to the Letterboxd API. The films are webscraped. Due to the limited information possible to gather from the films site, an algorithm was created to calculate a possible poster url. If this url does not exist a more time sensitive algorithm is used, that downloads a new site and extracts the poster url from that. After all the posters and films are collected. Each poster is evaluated with its main, dominant colour. These colours are later used to order the poster using a K-means sorting method. The colours are first sorted in groups and then those groups are then sorted by value, hue and saturation. After the lists are sorted the options are evaluated and the files are outputted as desired. If the data, of previous runs of the code, is in the directory that is being used, the list of films will only be updated. Within the code there are also options to not only update but start fresh. This option has to be activated in the code itself.