mercredi 1 février 2012

lm (list movies) EN

lm: list movies, a command-line tool

lm: list movies, a command-line tool

*lm* is a command-line tool which lists movies, loosely inspired from ls. Extra features allow you to download subtitles, and interact with the opensubtitles hash database. *lm* is not english oriented, and is able to provide information for all movie files.

lien vers la version Française


1 Introduction

1.1 History

The starting point of this little project is here at Goffi’s website. His idea was to build a command-line tool to list/filter/sort movies in current directory, using IMDbPy package to get all metadata information. When I saw the script, few months ago, I just made some modifications I though useful like displaying results in an html page with links to trailers, etc... Little by little, I realized it was a great tool to keep track of files without too much effort.


1.2 Brief features overview

Here is a short list of what you can do with *lm*:
  • list all movie files in current directory (recursive search) in your terminal
    • filter by genre, actor, country, file size
    • sort by name, rating
  • export this list to an html view
    • with cover
    • link to trailers and IMDb page
  • download subtitles in any languages (source


1.3 Underlying tools

*lm* uses Opensubtitles API through XMLRPC protocol (default python’s module xmlrpclib)  to match movie file hash with their database. If a movie file hash is not know by Opensubtitles, you can send them the information with *lm*, and then participate to this collaborative referencing.
IMDb provides all metadata information (genre, actors, outline, etc...), and is called through imdbpy package.


2 Installation


IMDbPy (required)

Check the very complete official download page, you will probably see that it’s available in the package repository of your distribution. Some (un)official installers are built for Mac Os X and Windows.
IMDbPY requires *lxml* module to speed up parsing. If it’s not installed, make sure to have BeautifulSoup instead.
Note: If you’d like to install it from sources, you may just stick to the minimal configuration.


colorama (optional, for windows users only)

*lm* is mainly designed to return results on a terminal, like *ls* function. To ’map’ terminal coloration on the windows terminal, please install this package.


3 Features in details

Let’s suppose we are in a folder with following files:

    Cinema Paradiso/


3.1 Options


Basic call

xx@xx/films$ ./  
Attack the Block (Attack.the.Block.avi) 
Dogville (DOGVILLE-2003.mkv) 
Nuovo Cinema Paradiso (1988.Cinema.Paradiso.mkv)

Lists all files in dir and sub dirs, sorted by name with minimal description displayed.


Longer description (-l)

xx@xx/films$ ./ -l 
Attack the Block (2011,6.8,4475Mo) [Comedy, Horror, Sci-Fi] 
from Joe Cornish: Attack.the.Block.avi 
Dogville (2003,8.0,3640Mo) [Drama, Mystery, Thriller] from
Lars von Trier: DOGVILLE-2003.mkv 
Nuovo Cinema Paradiso (1988,8.5,8137Mo) [Drama] from Giuseppe Tornatore: 1988.Cinema.Paradiso.mkv  
Displays year, imdb rating, file size, genres and directors.


Outline (-o)

[+/-] show/hide this output

>xx@xx/films$ ./ -o
Attack the Block (Attack.the.Block.avi) 
*** A teen gang in South London defend their block from an 
alien invasion. 
Dogville (DOGVILLE-2003.mkv) 
*** A woman on the run from the mob is reluctantly accepted in a small Colorado town. In exchange, 
she agrees to work for them. As a search visits town, she 
finds out that their support has a price. Yet her dangerous
secret is never far away... 
Nuovo Cinema Paradiso (1988.Cinema.Paradiso.mkv) 
*** A filmmaker recalls his childhood, when he fell in love 
with the movies at his village’s theater and formed a deep 
friendship with the theater’s projectionist.


Longest description (-L)

xx@xx/films$ ./ -L
Try it! Actors, and long outline are displayed.


Open result in an html page (-S)

xx@xx/films$ ./ -S
Attack the Block
Comedy, Horror
note: 6.8, votes: 26.0K
size: 4475Mo

Drama, Mystery
note: 8.0, votes: 59.0K
size: 3640Mo

Nuovo Cinema Paradiso
note: 8.5, votes: 62.0K
size: 8137Mo


This view has direct links to movie trailers (click on covers) and IMDb movie pages (click on title).


Open IMDb page (-s)

xx@xx/films$ ./ -s
Will open IMDb pages, pointing on every selected movies. Be careful and don’t use this parameter when too many movie files are selected.


Filter files (-f @xx:yy)

You can filter movies with the following syntax: “@keyword:filter,filter,filter@keyword2:filter,filter”. Filter is case insensitive.
xx@xx/films$ ./ -f @genre:drama
xx@xx/films$ ./ -f @genre:drama@size:+2000
You can filter by genre, country, actors, size (@size:+900 or @size:-400), and by identification confidence (@unsure). Check color interpretation part of this page.


3.2 Color interpretation

When displayed in your terminal, titles can have different colors.


The best! It means that your movie hash matches an Opensubtitles known movie. 95% sure to display the right title.


Not bad. We did’nt find any matches in Opensubtitles, but we looked through IMDb, and are quite confident. 80% chance to display the right title.

ORANGE with /|\ symbols:

We didn’t find anything on Opensubtitles, and we didn’t find any good matches in IMDb results either. We strongly recommend you to manually confirm this movie with the shell interactive command: YOUR_DIR -f @unsure --confirm.


3.3 Actions


Download subtitles (--donwload language)

xx@xx/films$ ./ --download eng
Looks for subtitles on Opensubtitles database. By order of preference, *lm* chooses first: perfect file hash match, and if nothing is found, it looks for most downloaded subtitles linked to this imdb id. Subtitles files are downloaded into every movie file directory with the syntax “” (replace ENG with chosen language). Up to 3 subtitles are donwloaded per movie.
limit: Opensubtitles limits downloads to 200 per day, please take this into consideration and don’t overload them!
language: please provide a ISO639 code as described HERE. eng/fre/ger are some examples.
503 Service Unavailable: Sometimes, Opensubtitles server is unreachable. Try again a few minutes/hours later.


Manually search/confirm movie (--confirm)

This command will take you through a confirmation process. You may have to provide other information to accurately identify the movies (imdb id, title or year).
[+/-] afficher/cacher cette procédure

>xx@xx/films$ ./

*************** File to confirm *************** 
absolute path : ~/films/dogville/DOGVILLE-2003.mkv 
basename : DOGVILLE-2003.mkv

Dogville (2003,8.0,3640Mo) [Drama, Mystery, Thriller] 
from Lars von Trier: DOGVILLE-2003.mkv 

Do you confirm stored info? (y/n):n 
Will you provide an IMDb id? (y/n):n 
please enter movie title: dogville 
please enter year, leave blank if unknown: 2003 

ratio <0.7 & year, we retry on base results 
ratio ==> dogville (for [dogville]) 1.000000 
--> movie found title: Dogville 
--> movie found year: 2003 
Confirm this result? (y/n):y 
movie saved


Upload movie hash and imdb id to Opensubtitles (--upload)

Selects all movies whose hash was not found on Opensubtitles but whose title was found on IMDb, and send (hash, imdb id) couple to Opensubtitles database. You will be asked to confirm before processing.


Delete files from cache (-d)

Delete selected movies from cache. You will be asked to confirm before processing. To delete all cache call: "./ cache -d"


Reset cache (--reset)

Delete every cache file (stored in ~/.lm/ directory). You will be asked to confirm before processing.


4 Miscellaneous


IMDb downloads are long

Advice: Each time you launch *lm*, it gets metadata for files it doesn’t know, which is really slow. So, make sure to test it on a directory with a few movies.




Hidden files

Basically, all metadata (text data, not pictures) are stored with cPickle in the hidden directory ~/.lm/.


Movie search

Here are the imdb searching steps:
  1. Build hash for file 
  2. Call Opensubtitles through XMLRPC protocol.
  3. Do they know this hash? If yes => perfect, we get an imdb_id and exit
  4. Otherwise, try to guess movie title/year from the filename (omit some stop words and look for a potential year in the movie filename)
  5. Send guessed title to IMDB, get the list of results
  6. If we guessed a year (at step 4), limit results to movies released this year
  7. Find the best match on all results, for ALL AKAS (non original titles)
  8. If the best match isn’t good enough, and if we filtered results at step 6, GOTO 7 with non-filtered imdb results.
Note: *lm* is not english oriented at all. Example "sexcrimes.avi" will match "wild things" its original title.

Aucun commentaire:

Enregistrer un commentaire