Create collections from a CSV list export from icheckmovies.com

 

I wanted to post a script I use to programatically tag collections from a list export from icheckmovies.com

 

Premium users of ICM can export top lists and this script will parse that CSV file and create a collection and tag any films in your Plex library that appear in that list.
 
For example, I can export the top 500 Essential Cult Movies list (https://www.icheckmovies.com/lists/500+essential+cult+movies/) and running the attached script I can create a collection called "500 Essential Cult Movies" and it will tag all the those movies that I own.
 
It works on linux and OSX.
 
================
 
 
Usage: create_plex_icm_collection.py [options]
    Options:
        -f CSVFILENAME, --file=CSVFILENAME        ICM top list CSV export [REQUIRED]
        -t "TAG TITLE", --tag="TAG TITLE"         Name of collection tag [REQUIRED]
        -x, --execute                             Commit changes to database, else dry run
        -r, --report                              Print list of films to tag and missing films
        -u, --untag                               Remove "TAG TITLE" from all listed films, essentially an undo
        -h, --help                                Show this help message and exit
 
    Example:
create_plex_icm_collection.py -f 500+essential+cult+movies.csv -t "500 Essential Cult Movies" -x -r
        The above will tag all owned movies from the .csv file with the tag "500 Essential Cult Movies", commit changes to database and print a report

 

 

 

 

In Mac OS uncomment this section in the file: 
#OSX    homedir = os.path.expanduser("~")
    conn = sqlite3.connect(
            '%s/Library/Application Support/Plex Media Server/Plug-in Support/'
            'Databases/com.plexapp.plugins.library.db' % (homedir))
    #conn = sqlite3.connect(
    #        '/var/lib/plexmediaserver/Library/Application Support/'
    #       'Plex Media Server/Plug-in Support/Databases/'
    #      'com.plexapp.plugins.library.db')
    cursor = conn.cursor()
    return (conn, cursor)

 

 

Source: https://forums.plex.tv/topic/123014-creating-collection-from-icheckmovies-top-list-export/#entry732519

I’m curious if anyone has built an OS X App around this script by whymse?

As I’ve prepared on my media in Plex, creating lists (collections) is the one element that I need to implement to make it easy to access and find my content. If not the above script, does anyone have any tools that allows them to easily create Plex Collections from lists such as icheckmovies.com?

I have a large adult film library and since it’s gotten so big it can be hard to find say any movie with a specific actress in it. So I go through and create collections for any movie with XYZ actress in it. Using the Data18 scraper do you think something like this could even be possible?

Or actually even if I just took a CSV list i made myself; could I use it to tag my movies to make collections for me? For example I could use iafd.com which lists every movie a specfic performer has done. Then I put that in CSV and use this script to tag any of those movies i have as a collection. Thoughts?
Thanks

You need this headers in your CSV file:

rank,rankdifference,title,year,url,checkedcount,favouritecount,dislikedcount,officialtoplistcount,usertoplistcount,akatitle,imdburl,checked,favorite,disliked,watchlist,owned

But the script only uses the IMDB url. So while you add the value to “imdburl” should work.

This is a full header:

rank,rankdifference,title,year,url,checkedcount,favouritecount,dislikedcount,officialtoplistcount,usertoplistcount,akatitle,imdburl,checked,favorite,disliked,watchlist,owned
1,0,"Crazy Love",1987,http://www.icheckmovies.com/movies/crazy+love/,103,7,3,1,15,"Love Is a Dog from Hell",http://www.imdb.com/title/tt0092794/,"2015-10-12 13:53:38",no,no,no,no

But enough with the IMDB URL to work well:

rank,rankdifference,title,year,url,checkedcount,favouritecount,dislikedcount,officialtoplistcount,usertoplistcount,akatitle,imdburl,checked,favorite,disliked,watchlist,owned
,,,,,,,,,,,http://www.imdb.com/title/tt0092794/,,,,,

How to get all IMDB URL of movie titles where Dana DeArmond has acted?

Too easy. Open the profile of Dana DeArmond or any other actress on IMDB:

And now you use a script of Firefox called “CopyURLs”

“Allows you to copy only the URLs in a selected portion of text in a web page.”

https://addons.mozilla.org/en-US/firefox/addon/copyurls/?src=api

Also “Copy Link URL” that does the same.

“Copy the URLs of the selected links to clipboard.”

https://addons.mozilla.org/en-US/firefox/addon/copy-link-url/?src=userprofile

Select all the titles of the movies where Dana DeArmond acts and copies the IMDB-URL to the clipboard using the Forefox script. And then you add them in your CSV file.

Now you just have to use the script to create collections in Plex using your CSV file.

Download the file create_plex_icm_collection.py

Unzip it and put it on the desktop and put on the desktop also your CSV file.

In Mac OS uncomment this section in the script:

  #OSX
    homedir = os.path.expanduser("~")
    conn = sqlite3.connect(
            '%s/Library/Application Support/Plex Media Server/Plug-in Support/'
            'Databases/com.plexapp.plugins.library.db' % (homedir))
    #conn = sqlite3.connect(
    #        '/var/lib/plexmediaserver/Library/Application Support/'
    #       'Plex Media Server/Plug-in Support/Databases/'
    #      'com.plexapp.plugins.library.db')
    cursor = conn.cursor()
    return (conn, cursor)

Open the Terminal on Mac OS.

Write:

cd/Users/YOURUSER/Desktop

Write:

create_plex_icm_collection.py -f TheNameOfYourCSVFile.csv -t "The Name of your Collection" -x -r

Enter.

The above will tag all owned movies from the .csv file commit changes to Plex database and print a report.

Ready.

As a quick update to this for anyone unfamiliar with python and to add a bit more clarity to Robot2XL’s post for those trying to run this excellent script on Mac OS X.:

  1. On the section to uncomment/comment in the script… make that section look EXACTLY like the example above. In other words, uncomment (remove #) and comment (add #) to make it look exactly as it shows above. This one threw me at first as Robot2XL’s directions say to “uncomment this section”… so, I did as instructed and uncomment the whole section… which of course does not work.

  2. To run a python script in OS X terminal, you must use ‘python’ in front of the command… so, it should look like:

python create_plex_icm_collection.py -f TheNameOfYourCSVFile.csv -t “The Name of your Collection” -x -r
Robot2XL’s directions left that out.

Hope this helps others and many thanks to Robot2XL for his great script! (looks like Whymse may have been the one to write this script… so, thanks to him)!

  • JettLag

Robot2XL - I was able to get this to work for a few new Collections… then I ran into errors on every single new one I’m trying to create:

Error below:
create_plex_icm_collection.py:102: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
if i == tag_title and not untag:
Traceback (most recent call last):
File “create_plex_icm_collection.py”, line 283, in
main()
File “create_plex_icm_collection.py”, line 278, in main
update_metadata_items(cursor, meta_id, tag_title, untag)
File “create_plex_icm_collection.py”, line 104, in update_metadata_items
tags_collection = “%s|%s” % (tags_collection, tag_title)
UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe2 in position 0: ordinal not in range(128)

Any idea?

Maybe the name of your CSV file has spaces.

Right: My+Movie.csv or MyMovie.csv
Incorrect: My Movie.csv

Or perhaps the CSV file has a bad format.

If you create the list using the icheckmovies.com page you should have no problem.

Straight unedited download from icheckmovies.com and no spaces in the name of the file. I’m going to try to install a more recent version of Python and see what happens.

Here is the link to one of the lists I’m trying to create the collection off of - https://www.icheckmovies.com/lists/top+250/

Thanks and let me know if you have any other ideas.

cd /Users/YOURUSER/Desktop

./create_plex_icm_collection.py -f top+250.csv -t “Top 250” -x -r

Thanks. I’m aware how to type the command, however.

New version of Python didn’t have any affect. Also tried on another machine as well with the exact same problem. Both machines are running El Capitan. Odd that it worked for 2 Collection creations, then started failing with the unicodedecode error… I’ve also tried to debug that by setting python locale and a half dozen other fixes I found throughout the intrawebs for that Python error, to no avail.

Anyone know Python that well to debug this script?

Robot2xl - is it still working for you? If so, are you running El Capitan?

Needless to say, all my UNIX/LINUX skill are rustic to say the least. I use Fink successfully. The best part, I do not have to remember in which directory which application is running. Fink goes, finds it, and tells me which command to enter to mount the right directory. Further more, with the correct admin privileges, Fink will install the libraries in the correct Mac filing directory. Give it a try: http://www.finkproject.org/index.php?phpLang=en.

Does this script works on ubuntu?
I tried, but i have this error:

Traceback (most recent call last):
File “plex_icm_collection.py”, line 283, in
main()
File “plex_icm_collection.py”, line 272, in main
metadata_ids = fetch_film_ids(cursor, csv_filename)
File “plex_icm_collection.py”, line 176, in fetch_film_ids
imdburl = row[‘imdburl’]
KeyError: ‘imdburl’

The way I’ve automated the process so I can easily make updates to all my collections is by using the Automator app on Mac OS. I share the Automator file for anyone who wants to try it.

Instructions.

Download and unzip the attached file.

  1. Place the “PlexCollections” folder inside the macOS “Applications” folder
  2. Open the “Automator” application on macOS.
  3. Select the file “PlexAutomator”. (File / Open)
  4. Press execute. (The play button at the top right).

Ready.

In the Automator window you can add as many collections as you want by copying the path and specifying the name of the collection and the exact name of the CSV file (name should never have spaces). And do not forget to add the CSV file inside the folder called “CSV”

If there is an error, please check that Python is installed on your system.

The version at /System/Library/Frameworks/Python.framework is installed by Apple and is used by the system. It is version 3.6.2 in my case.

You may check that by:

which -a python python3

To check third version, use:

python3 --version

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.