<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-5767897053834308865</atom:id><lastBuildDate>Thu, 16 Oct 2025 07:04:20 +0000</lastBuildDate><category>api</category><category>console</category><category>file</category><category>film</category><category>imdb</category><category>imdbpy</category><category>list</category><category>lm</category><category>movie</category><category>opensubtitles</category><category>sous-titres</category><category>subtitles</category><category>terminal</category><category>xmlrpc</category><category>CRAN</category><category>R</category><category>apply</category><category>function</category><category>iterator</category><category>lambda</category><category>lapply</category><category>library</category><category>package</category><category>project</category><category>rolling</category><category>windows</category><title>Red Rise</title><description></description><link>http://redrises.blogspot.com/</link><managingEditor>noreply@blogger.com (Red Rise)</managingEditor><generator>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5767897053834308865.post-4042286144893229575</guid><pubDate>Thu, 02 Feb 2012 01:03:00 +0000</pubDate><atom:updated>2012-02-13T10:25:00.605-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">api</category><category domain="http://www.blogger.com/atom/ns#">console</category><category domain="http://www.blogger.com/atom/ns#">file</category><category domain="http://www.blogger.com/atom/ns#">film</category><category domain="http://www.blogger.com/atom/ns#">imdb</category><category domain="http://www.blogger.com/atom/ns#">imdbpy</category><category domain="http://www.blogger.com/atom/ns#">list</category><category domain="http://www.blogger.com/atom/ns#">lm</category><category domain="http://www.blogger.com/atom/ns#">movie</category><category domain="http://www.blogger.com/atom/ns#">opensubtitles</category><category domain="http://www.blogger.com/atom/ns#">sous-titres</category><category domain="http://www.blogger.com/atom/ns#">subtitles</category><category domain="http://www.blogger.com/atom/ns#">terminal</category><category domain="http://www.blogger.com/atom/ns#">xmlrpc</category><title>lm (list movies) EN</title><description>&lt;title&gt;lm: list movies, a command-line tool&lt;/title&gt;


&lt;br /&gt;
&lt;div id=&quot;globalWrapper&quot;&gt;
&lt;h1 class=&quot;title&quot; style=&quot;text-align: center;&quot;&gt;
























lm: list movies, a command-line tool
&lt;/h1&gt;
&lt;div style=&quot;background-color: #eeeeee; text-align: center;&quot;&gt;
*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.
&lt;/div&gt;
&lt;h1 class=&quot;Section&quot; style=&quot;text-align: center;&quot;&gt;






&lt;a href=&quot;http://redrises.blogspot.com/2012/02/lm-list-movies-command-line-tool-lm.html&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;lien vers la version Française&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h1&gt;
&lt;h1 class=&quot;Section&quot; style=&quot;text-align: left;&quot;&gt;






&lt;span style=&quot;font-size: small;&quot;&gt;&lt;i&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;a href=&quot;https://github.com/RedRise/lm&quot;&gt;DOWNLOAD LM&lt;/a&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;h1 class=&quot;Section&quot;&gt;






&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;h1 class=&quot;Section&quot;&gt;
























1 Introduction
&lt;/h1&gt;
&lt;h3&gt;









1.1 History
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
The starting point of this little project is &lt;a href=&quot;http://www.goffi.org/index.php?post/2010/07/19/lm-%28list-movies%29%3A-un-outil-en-ligne-de-commande-pour-lister-vos-films&quot;&gt;here&lt;/a&gt; at &lt;b&gt;Goffi&lt;/b&gt;’s website. His idea was to build a command-line tool to list/filter/sort movies in current directory, using &lt;a href=&quot;http://imdbpy.sourceforge.net/&quot;&gt;IMDbPy package&lt;/a&gt; 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.
&lt;/div&gt;
&lt;h3 class=&quot;Subsection&quot;&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3 class=&quot;Subsection&quot;&gt;






















1.2 Brief features overview
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Here is a short list of what you can do with *lm*:
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
list all movie files in current directory (recursive search) in your terminal&lt;ul&gt;
&lt;li&gt;
filter by genre, actor, country, file size
&lt;/li&gt;
&lt;li&gt;
sort by name, rating
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
export this list to an html view&lt;ul&gt;
&lt;li&gt;
with cover
&lt;/li&gt;
&lt;li&gt;
link to trailers and IMDb page
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
download subtitles in any languages (source opensubtitles.org)
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 class=&quot;Subsection&quot;&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3 class=&quot;Subsection&quot;&gt;






















1.3 Underlying tools
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
*lm* uses &lt;a href=&quot;http://trac.opensubtitles.org/projects/opensubtitles/wiki/XMLRPC&quot;&gt;Opensubtitles API&lt;/a&gt; through XMLRPC protocol (default python’s module xmlrpclib)&amp;nbsp; 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.
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
IMDb provides all metadata information (genre, actors, outline, etc...), and is called through imdbpy package.
&lt;/div&gt;
&lt;h1 class=&quot;Section&quot;&gt;






















&amp;nbsp;&lt;/h1&gt;
&lt;h1 class=&quot;Section&quot;&gt;






















2 Installation
&lt;/h1&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















IMDbPy (required)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
&lt;a href=&quot;http://imdbpy.sourceforge.net/&quot;&gt;web page&lt;/a&gt; 
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
Check the very complete official &lt;a href=&quot;http://imdbpy.sourceforge.net/downloads.html&quot;&gt;download page&lt;/a&gt;, 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.
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
IMDbPY requires *lxml* module to speed up parsing. If it’s not installed, make sure to have &lt;a href=&quot;http://www.crummy.com/software/BeautifulSoup/&quot;&gt;BeautifulSoup&lt;/a&gt; instead. 
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
&lt;b&gt;Note&lt;/b&gt;: If you’d like to install it from sources, you may just stick to the minimal configuration.
&lt;/div&gt;
&lt;h3&gt;
























&lt;a class=&quot;toc&quot; href=&quot;http://www.blogger.com/blogger.g?blogID=5767897053834308865&quot; name=&quot;toc-Subsubsection--2&quot;&gt;&lt;/a&gt;&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















colorama (optional, for windows users only)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
&lt;a href=&quot;http://pypi.python.org/pypi/colorama&quot;&gt;web page&lt;/a&gt;&amp;nbsp;
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
*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.
&lt;/div&gt;
&lt;h1 class=&quot;Section&quot;&gt;






















&amp;nbsp;&lt;/h1&gt;
&lt;h1 class=&quot;Section&quot;&gt;






















3 Features in details
&lt;/h1&gt;
Let’s suppose we are in a folder with following files:&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div id=&quot;globalWrapper&quot;&gt;
&lt;pre&gt;/films/
    Cinema Paradiso/
        1988.Cinema.Paradiso.mkv
    ATB/
        Attack.the.Block.avi
    dogville/
        DOGVILLE-2003.mkv
        trailer.avi
&lt;/pre&gt;
&lt;h3 class=&quot;Subsection&quot;&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3 class=&quot;Subsection&quot;&gt;






















3.1 Options
&lt;/h3&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Basic call
&lt;/h3&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;&lt;span style=&quot;font-size: large;&quot;&gt;xx@xx/films$ ./lm.py  
&lt;span style=&quot;color: magenta;&quot;&gt;Attack the Block&lt;/span&gt; (Attack.the.Block.avi) 
&lt;span style=&quot;color: magenta;&quot;&gt;Dogville&lt;/span&gt; (DOGVILLE-2003.mkv) 
&lt;span style=&quot;color: magenta;&quot;&gt;Nuovo Cinema Paradiso&lt;/span&gt; (1988.Cinema.Paradiso.mkv)&lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
&lt;br /&gt;
Lists all files in dir and sub dirs, sorted by name with minimal description displayed.
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Longer description (-l)
&lt;/h3&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@&lt;span style=&quot;font-size: large;&quot;&gt;xx/films$ ./lm.py -l 
&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: large;&quot;&gt;Attack the Block&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; (2011,6.8,4475Mo) &lt;span style=&quot;color: #3d85c6;&quot;&gt;[Comedy, Horror, Sci-Fi] &lt;/span&gt;
from Joe Cornish: Attack.the.Block.avi 
&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: large;&quot;&gt;Dogville&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; (2003,8.0,3640Mo) &lt;span style=&quot;color: #3d85c6;&quot;&gt;[Drama, Mystery, Thriller]&lt;/span&gt; from&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Lars von Trier: DOGVILLE-2003.mkv 
&lt;/span&gt;&lt;span style=&quot;color: magenta; font-size: large;&quot;&gt;Nuovo Cinema Paradiso&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt; (1988,8.5,8137Mo) &lt;span style=&quot;color: #3d85c6;&quot;&gt;[Drama] &lt;/span&gt;from&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Giuseppe Tornatore: 1988.Cinema.Paradiso.mkv  &lt;/span&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Displays year, imdb rating, file size, genres and directors.
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Outline (-o)
&lt;/h3&gt;
&lt;a href=&quot;javascript:expandcollapse(&#39;$article2_item2$&#39;)&quot;&gt;[+/-] show/hide this output&lt;/a&gt;
&lt;br /&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;&lt;span class=&quot;posthidden&quot; id=&quot;$article2_item2$&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;
&amp;gt;xx@xx/films$ ./lm.py -o
&lt;span style=&quot;color: magenta;&quot;&gt;Attack the Block&lt;/span&gt; (Attack.the.Block.avi) 
*** A teen gang in South London defend their block from an&amp;nbsp;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;alien invasion. 
&lt;span style=&quot;color: magenta;&quot;&gt;Dogville&lt;/span&gt; (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&amp;nbsp;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;finds out that their support has a price. Yet her dangerous&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;secret is never far away... 
&lt;span style=&quot;color: magenta;&quot;&gt;Nuovo Cinema Paradiso&lt;/span&gt; (1988.Cinema.Paradiso.mkv) 
*** A filmmaker recalls his childhood, when he fell in love&amp;nbsp;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;with the movies at his village’s theater and formed a deep&amp;nbsp;&lt;/span&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;friendship with the theater’s projectionist.&lt;/span&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Longest description (-L)
&lt;/h3&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@xx/films$ ./lm.py -L
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Try it! Actors, and long outline are displayed.
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Open result in an html page (-S)
&lt;/h3&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@xx/films$ ./lm.py -S
&lt;/pre&gt;
&lt;/div&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr height=&quot;200&quot;&gt;&lt;td height=&quot;250&quot; width=&quot;200&quot;&gt;&lt;a href=&quot;http://www.imdb.com/title/tt1478964&quot;&gt;Attack the Block&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey;&quot;&gt;
 Comedy, Horror&lt;br /&gt;
 note: 6.8, votes: 26.0K&lt;br /&gt;
 size: 4475Mo&lt;br /&gt;
 &lt;/span&gt;
 &lt;a href=&quot;http://www.youtube.com/results?search_query=Attack+the+Block+trailer&quot;&gt;
  &lt;img height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwA6wVZz1FSl6Sa0VUujEnJMTifmoXXDqwN_czyS8KeuY6N6R6AwPaf7Rxe-MaI08-CttRCuylKoHP8YrjX_jKJLzptv1XbPpNEsw7M-2u-ecmpmNLrPft704fTpUMVy_0unHfawJMc-U/s1600/AZB.jpg&quot; /&gt;
 &lt;/a&gt;&lt;br /&gt;
&lt;small&gt;ATB-ATTACK-THE-BLOCK&lt;/small&gt;&lt;/td&gt;
 &lt;td height=&quot;250&quot; width=&quot;200&quot;&gt;&lt;a href=&quot;http://www.imdb.com/title/tt0276919&quot;&gt;
 Dogville&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey;&quot;&gt;Drama, Mystery&lt;br /&gt;
 note: 8.0, votes: 59.0K&lt;br /&gt;
 size: 3640Mo&lt;br /&gt;
 &lt;/span&gt;
 &lt;a href=&quot;http://www.youtube.com/results?search_query=Dogville+trailer&quot;&gt;
 &lt;img height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhKXN8Ry07jZL9o48BagU4HKtAlV1n7vtaF7VpzisCIY8a2Yjo09u4xFApjXACFiLM8oB-9WfAM_jmfT8cbsL8POkizS_GOcaGZKLCnqS8-yzsXqgx-TMTq_9hNevq5LNlTttrL0fMQVQ/s1600/DOGVILLE.jpg&quot; /&gt;
 &lt;/a&gt;&lt;br /&gt;
&lt;small&gt;DOGVILLE-2003.mkv&lt;/small&gt;&lt;/td&gt;
 &lt;td height=&quot;250&quot; width=&quot;200&quot;&gt;&lt;a href=&quot;http://www.imdb.com/title/tt0095765&quot;&gt;
 Nuovo Cinema Paradiso&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey;&quot;&gt;Drama&lt;br /&gt;
 note: 8.5, votes: 62.0K&lt;br /&gt;
 size: 8137Mo&lt;/span&gt;
 &lt;a href=&quot;http://www.youtube.com/results?search_query=Nuovo+Cinema+Paradiso+trailer&quot;&gt;
 &lt;img height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicgbUyRDoYDKLFOYX1Qocr8MXlbof5XY9wYV6ilgDgskTL0icS6NZB8wiuMeux6epKlLKYDs6UPnDyglCmdlvTVjMIVIkQMiGa8dmGlgGQff-n231b6yDWvQSU8V88FerMzdjXMcqsk6k/s1600/CP.jpg&quot; /&gt;
 &lt;/a&gt;&lt;br /&gt;
&lt;small&gt;1988.Cinema.Paradiso.mkv&lt;/small&gt;
 &lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;div class=&quot;Unindented&quot;&gt;
&lt;br /&gt;
This view has direct links to movie trailers (click on covers) and IMDb movie pages (click on title).
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Open IMDb page (-s)
&lt;/h3&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@xx/films$ ./lm.py -s
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Will open IMDb pages, pointing on every selected movies. Be careful and don’t use this parameter when too many movie files are selected.
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Filter files (-f @xx:yy)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
You can filter movies with the following syntax: “@keyword:filter,filter,filter@keyword2:filter,filter”. Filter is case insensitive.
&lt;/div&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@xx/films$ ./lm.py -f @genre:drama
...
xx@xx/films$ ./lm.py -f @genre:drama@size:+2000
...
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
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.
&lt;/div&gt;
&lt;h3 class=&quot;Subsection&quot;&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3 class=&quot;Subsection&quot;&gt;






















3.2 Color interpretation
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
When displayed in your terminal, titles can have different colors. 
&lt;/div&gt;
&lt;h3&gt;
























&lt;a class=&quot;toc&quot; href=&quot;http://www.blogger.com/blogger.g?blogID=5767897053834308865&quot; name=&quot;toc-Subsubsection--10&quot;&gt;&lt;/a&gt;&lt;span style=&quot;color: magenta;&quot;&gt;MAGENTA&lt;/span&gt; 
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
The best! It means that your movie hash matches an Opensubtitles known movie. 95% sure to display the right title.
&lt;/div&gt;
&lt;h3&gt;
























&lt;a class=&quot;toc&quot; href=&quot;http://www.blogger.com/blogger.g?blogID=5767897053834308865&quot; name=&quot;toc-Subsubsection--11&quot;&gt;&lt;/a&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;ORANGE &lt;/span&gt;
&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
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.
&lt;/div&gt;
&lt;h3&gt;
























&lt;a class=&quot;toc&quot; href=&quot;http://www.blogger.com/blogger.g?blogID=5767897053834308865&quot; name=&quot;toc-Subsubsection--12&quot;&gt;&lt;/a&gt;&lt;span style=&quot;color: orange;&quot;&gt;ORANGE&lt;/span&gt; with &lt;span style=&quot;color: red;&quot;&gt;/|\&lt;/span&gt; symbols: 
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
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: lm.py YOUR_DIR -f @unsure --confirm.
&lt;/div&gt;
&lt;h3 class=&quot;Subsection&quot;&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3 class=&quot;Subsection&quot;&gt;






















3.3 Actions
&lt;/h3&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Download subtitles (--donwload language)
&lt;/h3&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@xx/films$ ./lm.py --download eng
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
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 “MOVIEFILENAME_ENG_LM1.srt” (replace ENG with chosen language). Up to 3 subtitles are donwloaded per movie.
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
&lt;b&gt;limit&lt;/b&gt;: Opensubtitles limits downloads to 200 per day, please take this into consideration and don’t overload them!
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
&lt;b&gt;language&lt;/b&gt;: please provide a ISO639 code as described &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes&quot;&gt;HERE&lt;/a&gt;. eng/fre/ger are some examples.
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
&lt;b&gt;503 Service Unavailable: &lt;/b&gt;Sometimes, Opensubtitles server is unreachable. Try again a few minutes/hours later.
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Manually search/confirm movie (--confirm)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
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).
&lt;/div&gt;
&lt;a href=&quot;javascript:expandcollapse(&#39;$article2_item1$&#39;)&quot;&gt;[+/-] afficher/cacher cette procédure&lt;/a&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;&lt;span class=&quot;posthidden&quot; id=&quot;$article2_item1$&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;
&amp;gt;xx@xx/films$ ./lm.py--confirm

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

&lt;span style=&quot;color: magenta;&quot;&gt;Dogville&lt;/span&gt; (2003,8.0,3640Mo) &lt;span style=&quot;color: #3d85c6;&quot;&gt;[Drama, Mystery, Thriller]&lt;/span&gt; 
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 &amp;lt;0.7 &amp;amp; year, we retry on base results 
ratio ==&amp;gt; dogville (for [dogville]) 1.000000 
--&amp;gt; movie found title: Dogville 
--&amp;gt; movie found year: 2003 
Confirm this result? (y/n):y 
movie saved&lt;/span&gt;

&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Upload movie hash and imdb id to Opensubtitles (--upload)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
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.
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Delete files from cache (-d) 
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Delete selected movies from cache. You will be asked to confirm before processing. To delete all cache call: &quot;./lm.py cache -d&quot;
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Reset cache (--reset)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Delete every cache file (stored in ~/.lm/ directory). You will be asked to confirm before processing.
&lt;/div&gt;
&lt;h1 class=&quot;Section&quot;&gt;






















&amp;nbsp;&lt;/h1&gt;
&lt;h1 class=&quot;Section&quot;&gt;






















4 Miscellaneous
&lt;/h1&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















IMDb downloads are long
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
&lt;b&gt;Advice&lt;/b&gt;: 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. 
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Mechanisms
&lt;/h3&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Hidden files
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Basically, all metadata (text data, not pictures) are stored with cPickle in the hidden directory ~/.lm/.
&lt;/div&gt;
&lt;h3&gt;






















&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;






















Movie search
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Here are the imdb searching steps:
&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;a href=&quot;http://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes&quot;&gt;Build hash for file&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Call Opensubtitles through XMLRPC protocol. 
&lt;/li&gt;
&lt;li&gt;
Do they know this hash? If yes =&amp;gt; perfect, we get an imdb_id and exit
&lt;/li&gt;
&lt;li&gt;
Otherwise, try to guess movie title/year from the filename (omit some stop words and look for a potential year in the movie filename)
&lt;/li&gt;
&lt;li&gt;
Send guessed title to IMDB, get the list of results
&lt;/li&gt;
&lt;li&gt;
If we guessed a year (at step 4), limit results to movies released this year
&lt;/li&gt;
&lt;li&gt;
Find the best match on all results, for ALL AKAS (non original titles) 
&lt;/li&gt;
&lt;li&gt;
If the best match isn’t good enough, and if we filtered results at step 6, GOTO 7 with non-filtered imdb results.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Note: *lm* is not english oriented at all. Example &quot;sexcrimes.avi&quot; will match &quot;wild things&quot; its original title.
&lt;/div&gt;
&lt;hr class=&quot;footer&quot; style=&quot;background-color: #eeeeee; height: 2px;&quot; /&gt;
&lt;div class=&quot;footer&quot; id=&quot;generated-by&quot; style=&quot;background-color: #eeeeee;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;Document generated by &lt;a href=&quot;http://elyxer.nongnu.org/&quot;&gt;eLyXer 1.2.2 (2011-06-12)&lt;/a&gt; on &lt;/span&gt;&lt;span class=&quot;create-date&quot; style=&quot;font-size: x-small;&quot;&gt;2012-02-01T23:39:40.689418&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;</description><link>http://redrises.blogspot.com/2012/02/lm-list-movies-command-line-tool-lm_01.html</link><author>noreply@blogger.com (Red Rise)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwA6wVZz1FSl6Sa0VUujEnJMTifmoXXDqwN_czyS8KeuY6N6R6AwPaf7Rxe-MaI08-CttRCuylKoHP8YrjX_jKJLzptv1XbPpNEsw7M-2u-ecmpmNLrPft704fTpUMVy_0unHfawJMc-U/s72-c/AZB.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5767897053834308865.post-1688040213570943798</guid><pubDate>Thu, 02 Feb 2012 01:03:00 +0000</pubDate><atom:updated>2025-10-16T00:04:20.367-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">api</category><category domain="http://www.blogger.com/atom/ns#">console</category><category domain="http://www.blogger.com/atom/ns#">file</category><category domain="http://www.blogger.com/atom/ns#">film</category><category domain="http://www.blogger.com/atom/ns#">imdb</category><category domain="http://www.blogger.com/atom/ns#">imdbpy</category><category domain="http://www.blogger.com/atom/ns#">list</category><category domain="http://www.blogger.com/atom/ns#">lm</category><category domain="http://www.blogger.com/atom/ns#">movie</category><category domain="http://www.blogger.com/atom/ns#">opensubtitles</category><category domain="http://www.blogger.com/atom/ns#">sous-titres</category><category domain="http://www.blogger.com/atom/ns#">subtitles</category><category domain="http://www.blogger.com/atom/ns#">terminal</category><category domain="http://www.blogger.com/atom/ns#">xmlrpc</category><title>lm (list movies) FR</title><description>&lt;title&gt;lm: list movies, a command-line tool&lt;/title&gt;
&lt;br /&gt;
&lt;div id=&quot;globalWrapper&quot;&gt;
&lt;h1 class=&quot;title&quot; style=&quot;text-align: center;&quot;&gt;



  lm: list movies, un outil en ligne de commande
 &lt;/h1&gt;
&lt;div style=&quot;background-color: #eeeeee; text-align: center;&quot;&gt;
*lm* est un outil en ligne de commande (à la manière de ls?) permettant de lister les films présents dans le répertoire. Mais il permet aussi de télécharger les sous-titres correspondants et d’interagir avec la base de films d&#39;Opensubtitles. A noter: *lm* ne se limite pas aux fichiers à titres anglais.
 &lt;/div&gt;
&lt;h1 class=&quot;Section&quot; style=&quot;text-align: center;&quot;&gt;



&lt;span style=&quot;font-size: small; font-weight: normal;&quot;&gt;
 &lt;i&gt;
   &lt;a href=&quot;http://redrises.blogspot.com/2012/02/lm-list-movies-command-line-tool-lm_01.html&quot;&gt;
    for English version click here
   &lt;/a&gt;
 &lt;/i&gt;
&lt;/span&gt;
&lt;/h1&gt;
&lt;h1 class=&quot;Section&quot; style=&quot;text-align: left;&quot;&gt;



&lt;span style=&quot;font-size: small; font-weight: normal;&quot;&gt;
 &lt;i&gt;
  &lt;a href=&quot;https://github.com/RedRise/lm&quot;&gt;TELECHARGER LM&lt;/a&gt;
 &lt;/i&gt;
&lt;/span&gt;
&lt;/h1&gt;
&lt;h1&gt;



1 Introduction
&lt;/h1&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


1.1 Histoire
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Le point de départ de ce modeste projet se trouve &lt;a href=&quot;http://www.goffi.org/index.php?post/2010/07/19/lm-%28list-movies%29%3A-un-outil-en-ligne-de-commande-pour-lister-vos-films&quot;&gt;ICI&lt;/a&gt; sur le site de &lt;b&gt;Goffi&lt;/b&gt;. Son idée était de construire un outil en ligne de commande qui servirait à lister/filter/trier les films du répertoire en utilisant le &lt;a href=&quot;http://imdbpy.sourceforge.net/&quot;&gt;package IMDbPy&lt;/a&gt; pour récupérer toutes les métadonnées. Quand j&#39;ai découvert ce script, il y a quelques mois, j&#39;y ai juste apporté quelques modifications qui semblaient utiles, comme l&#39;affichage du résultat dans une page html avec des liens vers les bandes annonces, etc... Et petit à petit, j&#39;ai réalisé que *lm* était un outil fort pratique pour garder la trace de ses films. &lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


1.2 Petit tour rapide des fonctionnalités
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Voici une liste des utilisations principales de *lm*:
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
lister les films d&#39;un répertoire (recherche récursive) dans son terminal&lt;ul&gt;
&lt;li&gt;
filtrer par genre, acteurs, pays, taille de fichier
&lt;/li&gt;
&lt;li&gt;
trier par nom ou par note IMDb
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
exporter ces résultat dans une page html avec:&lt;br /&gt;&lt;ul&gt;
&lt;li&gt;
les affiches des films
&lt;/li&gt;
&lt;li&gt;
des liens vers les bandes annonces et les pages imdb
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
télécharger les sous-titres dans n&#39;importe quelle langue (source Opensubtitles.org)
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


1.3 Les outils utilisés&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
*lm* utilise &lt;a href=&quot;http://trac.opensubtitles.org/projects/opensubtitles/wiki/XMLRPC&quot;&gt;l&#39;API d&#39;Opensubtitles&lt;/a&gt; via le protocole XMLRPC (module python de la librairie standard: xmlrpclib) pour déterminer l&#39;id IMDb du film à partir du hash du fichier. Si le film n&#39;y est pas connu, *lm* pourra par la suite envoyer ces informations à Opensubtitles et ainsi participer à étoffer cette base de films.&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
IMDb fournit toutes les métadonnées des films. La base est interrogée grâce au module imdbpy.
&lt;/div&gt;
&lt;h1&gt;


&amp;nbsp;&lt;/h1&gt;
&lt;h1&gt;


2 Installation
&lt;/h1&gt;
&lt;h3&gt;



&lt;/h3&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


IMDbPy (requis)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
&lt;a href=&quot;http://imdbpy.sourceforge.net/&quot;&gt;site internet&lt;/a&gt; 
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
Faites un tour sur la page de &lt;a href=&quot;http://imdbpy.sourceforge.net/downloads.html&quot;&gt;téléchargement&lt;/a&gt; très complete. Vous y verrez sûrement que ce package est disponible sur le repo de votre distribution. Sinon, quelques installeurs (non)officiels sont disponibles pour&amp;nbsp; Mac Os X et Windows.
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
IMDbPY requiert le module *lxml* module pour accélérer le parsing. Si vous ne pouvez pas l&#39;installer, assurez vous d&#39;avoir &lt;a href=&quot;http://www.crummy.com/software/BeautifulSoup/&quot;&gt;BeautifulSoup&lt;/a&gt; à la place. 
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
&lt;b&gt;Note&lt;/b&gt;: Si vous souhaitez installer le package depuis les sources, vous pouvez vous contentez de la configuration minimale.
&lt;/div&gt;
&lt;h3&gt;



colorama (optionnel, pour les utilisateurs windows seulement)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
&lt;a href=&quot;http://pypi.python.org/pypi/colorama&quot;&gt;site internet&lt;/a&gt;&amp;nbsp;
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
*lm* est principalement déstiné à afficher ses résultats dans le terminal. Pour colorer le &quot;terminal&quot; windows , installez ce package.
&lt;/div&gt;
&lt;h1&gt;


&amp;nbsp;&lt;/h1&gt;
&lt;h1&gt;


3 lm en détails
&lt;/h1&gt;
Supposons l&#39;arborescence de répertoires/fichiers suivante:&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div id=&quot;globalWrapper&quot;&gt;
&lt;pre&gt;/films/
    Cinema Paradiso/
        1988.Cinema.Paradiso.mkv
    ATB/
        Attack.the.Block.avi
    dogville/
        DOGVILLE-2003.mkv
        trailer.avi
&lt;/pre&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


3.1 Options
&lt;/h3&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Appel simple
&lt;/h3&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@xx/films$ ./lm.py  
&lt;span style=&quot;color: magenta;&quot;&gt;Attack the Block&lt;/span&gt; (Attack.the.Block.avi) 
&lt;span style=&quot;color: magenta;&quot;&gt;Dogville&lt;/span&gt; (DOGVILLE-2003.mkv) 
&lt;span style=&quot;color: magenta;&quot;&gt;Nuovo Cinema Paradiso&lt;/span&gt; (1988.Cinema.Paradiso.mkv)
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
&lt;br /&gt;
Liste tous les films des répertoires et sous répertoires, triés par noms, avec un minimum d&#39;informations affichées.
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Description plus longue (-l)
&lt;/h3&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@xx/films$ ./lm.py -l 
&lt;span style=&quot;color: magenta;&quot;&gt;Attack the Block&lt;/span&gt; (2011,6.8,4475Mo) &lt;span style=&quot;color: #3d85c6;&quot;&gt;[Comedy, Horror, Sci-Fi] &lt;/span&gt;
from Joe Cornish: Attack.the.Block.avi 
&lt;span style=&quot;color: magenta;&quot;&gt;Dogville&lt;/span&gt; (2003,8.0,3640Mo) &lt;span style=&quot;color: #3d85c6;&quot;&gt;[Drama, Mystery, Thriller]&lt;/span&gt; from&amp;nbsp;
Lars von Trier: DOGVILLE-2003.mkv 
&lt;span style=&quot;color: magenta;&quot;&gt;Nuovo Cinema Paradiso&lt;/span&gt; (1988,8.5,8137Mo) &lt;span style=&quot;color: #3d85c6;&quot;&gt;[Drama] &lt;/span&gt;from&amp;nbsp;
Giuseppe Tornatore: 1988.Cinema.Paradiso.mkv
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
&lt;br /&gt;
Affiche l&#39;année, la note, la taille du fichier, le genre du film ainsi que le réalisateur.&amp;nbsp;
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Outline (-o)
&lt;/h3&gt;
&lt;a href=&quot;javascript:expandcollapse(&#39;$article2_item2$&#39;)&quot;&gt;[+/-] afficher/cacher le résultat&lt;/a&gt;
&lt;br /&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;&lt;span class=&quot;posthidden&quot; id=&quot;$article2_item2$&quot;&gt;
&amp;gt;xx@xx/films$ ./lm.py -o
&lt;span style=&quot;color: magenta;&quot;&gt;Attack the Block&lt;/span&gt; (Attack.the.Block.avi) 
*** A teen gang in South London defend their block from an&amp;nbsp;
alien invasion. 
&lt;span style=&quot;color: magenta;&quot;&gt;Dogville&lt;/span&gt; (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&amp;nbsp;
finds out that their support has a price. Yet her dangerous
secret is never far away... 
&lt;span style=&quot;color: magenta;&quot;&gt;Nuovo Cinema Paradiso&lt;/span&gt; (1988.Cinema.Paradiso.mkv) 
*** A filmmaker recalls his childhood, when he fell in love&amp;nbsp;
with the movies at his village’s theater and formed a deep&amp;nbsp;
friendship with the theater’s projectionist.
&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


La plus longue description (-L)
&lt;/h3&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@xx/films$ ./lm.py -L
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Essayez! Les acteurs, ainsi qu&#39;un résumé détaillé sont affichés.
&lt;/div&gt;
&lt;h3&gt;




&lt;/h3&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Afficher les résultats dans une page html (-S)
&lt;/h3&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@xx/films$ ./lm.py -S&lt;/pre&gt;
&lt;/div&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr height=&quot;200&quot;&gt;&lt;td height=&quot;250&quot; width=&quot;200&quot;&gt;&lt;a href=&quot;http://www.imdb.com/title/tt1478964&quot;&gt;Attack the Block&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey;&quot;&gt;
 Comedy, Horror&lt;br /&gt;
 note: 6.8, votes: 26.0K&lt;br /&gt;
 size: 4475Mo&lt;br /&gt;
 &lt;/span&gt;
 &lt;a href=&quot;http://www.youtube.com/results?search_query=Attack+the+Block+trailer&quot;&gt;
  &lt;img height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwA6wVZz1FSl6Sa0VUujEnJMTifmoXXDqwN_czyS8KeuY6N6R6AwPaf7Rxe-MaI08-CttRCuylKoHP8YrjX_jKJLzptv1XbPpNEsw7M-2u-ecmpmNLrPft704fTpUMVy_0unHfawJMc-U/s1600/AZB.jpg&quot; /&gt;
 &lt;/a&gt;&lt;br /&gt;
&lt;small&gt;ATB-ATTACK-THE-BLOCK&lt;/small&gt;&lt;/td&gt;
 &lt;td height=&quot;250&quot; width=&quot;200&quot;&gt;&lt;a href=&quot;http://www.imdb.com/title/tt0276919&quot;&gt;
 Dogville&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey;&quot;&gt;Drama, Mystery&lt;br /&gt;
 note: 8.0, votes: 59.0K&lt;br /&gt;
 size: 3640Mo&lt;br /&gt;
 &lt;/span&gt;
 &lt;a href=&quot;http://www.youtube.com/results?search_query=Dogville+trailer&quot;&gt;
 &lt;img height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhKXN8Ry07jZL9o48BagU4HKtAlV1n7vtaF7VpzisCIY8a2Yjo09u4xFApjXACFiLM8oB-9WfAM_jmfT8cbsL8POkizS_GOcaGZKLCnqS8-yzsXqgx-TMTq_9hNevq5LNlTttrL0fMQVQ/s1600/DOGVILLE.jpg&quot; /&gt;
 &lt;/a&gt;&lt;br /&gt;
&lt;small&gt;DOGVILLE-2003.mkv&lt;/small&gt;&lt;/td&gt;
 &lt;td height=&quot;250&quot; width=&quot;200&quot;&gt;&lt;a href=&quot;http://www.imdb.com/title/tt0095765&quot;&gt;
 Nuovo Cinema Paradiso&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;color: grey;&quot;&gt;Drama&lt;br /&gt;
 note: 8.5, votes: 62.0K&lt;br /&gt;
 size: 8137Mo&lt;/span&gt;
 &lt;a href=&quot;http://www.youtube.com/results?search_query=Nuovo+Cinema+Paradiso+trailer&quot;&gt;
 &lt;img height=&quot;150&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicgbUyRDoYDKLFOYX1Qocr8MXlbof5XY9wYV6ilgDgskTL0icS6NZB8wiuMeux6epKlLKYDs6UPnDyglCmdlvTVjMIVIkQMiGa8dmGlgGQff-n231b6yDWvQSU8V88FerMzdjXMcqsk6k/s1600/CP.jpg&quot; /&gt;
 &lt;/a&gt;&lt;br /&gt;
&lt;small&gt;1988.Cinema.Paradiso.mkv&lt;/small&gt;
 &lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Cette vue à des liens vers les bandes annonces (cliquez sur l&#39;affiche) et les pages imdb (cliquez sur les titres des films).
&lt;/div&gt;
&lt;br /&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Ouvrir la page imdb (-s)
&lt;/h3&gt;
&lt;br /&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Ouvre directement les pages IMDb des films sélectionnés. Soyez prudents, et n&#39;utilisez pas ce paramètre si trop d&#39;éléments risquent d&#39;être affichés.
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Filtrer les films (-f @xx:yy)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Syntaxe: “@keyword:filter,filter,filter@keyword2:filter,filter” (n&#39;est pas sensible à la casse).
&lt;/div&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@xx/films$ ./lm.py -f @genre:drama
...
xx@xx/films$ ./lm.py -f @genre:drama@size:+2000
...
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Vous pouvez filtrer par genre, acteurs, parys, taille de fichier (ex: @size:+900 ou @size:-400), mais aussi par pertinence de la reconnaissance du titre (@unsure). Lisez la partie suivante sur les couleurs utilisées pour en savoir plus sur les erreurs d&#39;identification.
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


3.2 Interprétation des couleurs affichées
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Quand les films s&#39;affichent dans le terminal, les titres peuvent prendre plusieurs couleurs. 
&lt;/div&gt;
&lt;h3&gt;



&lt;span style=&quot;color: magenta;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/h3&gt;
&lt;h3&gt;


&lt;span style=&quot;color: magenta;&quot;&gt;MAGENTA&lt;/span&gt; 
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Le top! Le hash du film a été trouvé dans la base Opensubtitles. 95% de chances de pointer le bon titre.
&lt;/div&gt;
&lt;h3&gt;



&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;h3&gt;


&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;color: orange;&quot;&gt;ORANGE &lt;/span&gt;
&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Pas si mal. *lm* n&#39;a pas trouvé le hash du fichier, mais la recherche directe sur IMDb a donné un bon résultat, *lm* est assez confiant. 80% de chance d&#39;afficher le bon titre.&lt;/div&gt;
&lt;h3&gt;



&lt;span style=&quot;color: orange;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/h3&gt;
&lt;h3&gt;


&lt;span style=&quot;color: orange;&quot;&gt;ORANGE&lt;/span&gt; avec des symboles &lt;span style=&quot;color: red;&quot;&gt;/|\&lt;/span&gt; : 
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Aïe! Le hash n&#39;a rien donné sur Opensubtitles, et la recherche directe par IMDb n&#39;a pas donné de résultat satisfaisant non plus. Il y a des chances que le titre indiqué ne soit pas bon. Il est conseillé de lancer une confirmation manuelle de l&#39;ensemble de ces titres avec la commande &quot;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;&quot;&gt;lm.py YOUR_DIR -f @unsure --confirm&lt;/span&gt;&quot;.
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


3.3 Actions
&lt;/h3&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Télécharger les sous-titres (--donwload language)
&lt;/h3&gt;
&lt;div lyx-code&quot;=&quot;&quot; style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;xx@xx/films$ ./lm.py --download eng
&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Recherche les sous-titres sur la base Opensubtitles. Par ordre de préférence seront téléchargés, les sous-titres pointant vers les hashs exacts des fichiers détenus, puis les sous-titres les plus téléchargés parmi ceux associés aux bons id IMDb. Les sous-titres sont téléchargés dans les répertoires de chaque film avec la syntaxe “MOVIEFILENAME_ENG_LM1.srt” (replacer ENG par la langue choisie). Au plus 3 sous-titres seront téléchargés par film.
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
&lt;b&gt;limit&lt;/b&gt;e: Opensubtitles limite à 200 téléchargements par jour. Merci de prendre cette limite en considération et d&#39;éviter de saturer leur serveur!
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
&lt;b&gt;langue&lt;/b&gt;: Fournir un code ISO639 comme décrit &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes&quot;&gt;ICI&lt;/a&gt;. eng/fre/ger en sont des exemples.
&lt;/div&gt;
&lt;div class=&quot;Indented&quot;&gt;
&lt;b&gt;503 Service Unavailable: &lt;/b&gt;Il arrive parfois que le serveur Opensubtitles soit saturé. Ré-essayez quelques minutes/heures plus tard.
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Recherche/confirmation manuelle (--confirm)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Cette commande lance une procédure qui vous accompagne dans la recherche ou confirmation des films sélectionnés. Si le titre associé ne vous correspond pas, vous pourrez fournir des information supplémentaires pour l&#39;identifier (titre, année, IMDb id).
&lt;/div&gt;
&lt;a href=&quot;javascript:expandcollapse(&#39;$article2_item1$&#39;)&quot;&gt;[+/-] afficher/cacher cette procédure&lt;/a&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: black; color: white;&quot;&gt;
&lt;pre&gt;&lt;span class=&quot;posthidden&quot; id=&quot;$article2_item1$&quot; style=&quot;font-size: large;&quot;&gt;
&amp;gt;xx@xx/films$ ./lm.py--confirm

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

&lt;span style=&quot;color: magenta;&quot;&gt;Dogville&lt;/span&gt; (2003,8.0,3640Mo) &lt;span style=&quot;color: #3d85c6;&quot;&gt;[Drama, Mystery, Thriller]&lt;/span&gt; 
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 &amp;lt;0.7 &amp;amp; year, we retry on base results 
ratio ==&amp;gt; dogville (for [dogville]) 1.000000 
--&amp;gt; movie found title: Dogville 
--&amp;gt; movie found year: 2003 
Confirm this result? (y/n):y 
movie saved

&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Uploader la paire (hash, id) à Opensubtitles (--upload)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Sélectionne les films dont les hashs n&#39;ont pas été trouvés sur Opensubtitles pour lesquels la recherche sur IMDb à fourni de bons résultats, et envoie la correspondance hash -&amp;gt; imdb_id à la base Opensubtitles. Une confirmation vous sera demandée avant tout effet.
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Supprimer des fichiers du cache (-d) 
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Supprime du cache les fichiers sélectionnés. Une confirmation vous sera demandée avant tout effet. Pour supprimer tous les fichiers du cache &quot;./lm.py cache -d&quot;
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Remettre le cache à zéro (--reset)
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Supprime directement tous les fichiers de cache stockés dans le répertoire ~/.lm.&amp;nbsp; Une confirmation vous sera demandée avant tout effet.
&lt;/div&gt;
&lt;h1&gt;


&amp;nbsp;&lt;/h1&gt;
&lt;h1&gt;


Divers
&lt;/h1&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Les appels à IMDb sont longs
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
&lt;b&gt;Conseil&lt;/b&gt;: quand *lm* est appelé sur des fichiers qu&#39;il ne connaît pas, il requête IMDb pour tous les fichiers inconnus, et c&#39;est ... lent. Pour tester le script, assurez vous de pointer un répertoire ne contenant que quelques films. 
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;



Fichiers cachés
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Tout est stocké dans le répertoire ~/.lm/.
&lt;/div&gt;
&lt;h3&gt;


&amp;nbsp;&lt;/h3&gt;
&lt;h3&gt;


Recherche de l&#39;id IMDb&lt;br /&gt;
&lt;/h3&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Voici les principales étapes:
&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;a href=&quot;http://trac.opensubtitles.org/projects/opensubtitles/wiki/HashSourceCodes&quot;&gt;Construire le hash du film&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Questionner Opensubtitles via leur api XMLRPC. 
&lt;/li&gt;
&lt;li&gt;Reconnaît-il ce hash? Si oui =&amp;gt; parfait, travail terminé, exit!
&lt;/li&gt;
&lt;li&gt;
Sinon, on essaye de deviner le titre et l&#39;année de sortie du film à partir du nom du fichier (mots interdit, regexp, ...)
&lt;/li&gt;
&lt;li&gt;On questionne IMDb pour le titre deviné. On récupère les résultats
&lt;/li&gt;
&lt;li&gt;Si nous pensions avoir détecter une année de sortie, les résultats sont filtrés pour ne conserver que les films de l&#39;année en question.
&lt;/li&gt;
&lt;li&gt;
Recherche de la meilleure correspondance entre les titres (devinés et résultats), sur les titres du films dans tous les pays disponibles
&lt;/li&gt;
&lt;li&gt;Si le meilleur résultat n&#39;est pas satisfaisant, et si nous avions deviné une année à l&#39;étape 6, on repasse à 7 avec les résultats initiaux (non filtrés) d&#39;IMDb.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;Unindented&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://redrises.blogspot.com/2012/02/lm-list-movies-command-line-tool-lm.html</link><author>noreply@blogger.com (Red Rise)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhwA6wVZz1FSl6Sa0VUujEnJMTifmoXXDqwN_czyS8KeuY6N6R6AwPaf7Rxe-MaI08-CttRCuylKoHP8YrjX_jKJLzptv1XbPpNEsw7M-2u-ecmpmNLrPft704fTpUMVy_0unHfawJMc-U/s72-c/AZB.jpg" height="72" width="72"/><thr:total>12</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5767897053834308865.post-2585261290844475524</guid><pubDate>Wed, 18 Jan 2012 23:32:00 +0000</pubDate><atom:updated>2012-02-02T00:07:01.373-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">apply</category><category domain="http://www.blogger.com/atom/ns#">CRAN</category><category domain="http://www.blogger.com/atom/ns#">function</category><category domain="http://www.blogger.com/atom/ns#">iterator</category><category domain="http://www.blogger.com/atom/ns#">lambda</category><category domain="http://www.blogger.com/atom/ns#">lapply</category><category domain="http://www.blogger.com/atom/ns#">library</category><category domain="http://www.blogger.com/atom/ns#">package</category><category domain="http://www.blogger.com/atom/ns#">project</category><category domain="http://www.blogger.com/atom/ns#">R</category><category domain="http://www.blogger.com/atom/ns#">rolling</category><category domain="http://www.blogger.com/atom/ns#">windows</category><title>R package lambda</title><description>&lt;title&gt;lambda: An R package for an easier iteration coding&lt;/title&gt;


&lt;br /&gt;
&lt;div id=&quot;globalWrapper&quot;&gt;
&lt;h1 class=&quot;title&quot; style=&quot;text-align: center;&quot;&gt;

















lambda: An R package for an easier iteration coding
&lt;/h1&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;pre class=&quot;LyX-Code&quot;&gt;Package: lambda
Version: 1.0
Date: 2012-01-11
Author: eOnOs
Maintainer: contact me!
License: GPL-3&lt;/pre&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;pre class=&quot;LyX-Code&quot;&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class=&quot;LyX-Code&quot;&gt;You can download the package &lt;a href=&quot;https://github.com/RedRise/lambda/blob/master/lambda_1.0.tar.gz&quot;&gt;HERE&lt;/a&gt; and run from R the command:
install.packages(&quot;lambda_1.0.tar.gz&quot;, type=&quot;source&quot;, repos=NULL)

&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h1 class=&quot;Section&quot;&gt;

















Introduction
&lt;/h1&gt;
&lt;div class=&quot;Unindented&quot;&gt;
As you know, ’for’ loops are forbidden in R. You should prefer vectorialized tools provided in base package to run your computations. But sometimes, you need to go through your data in a particular way that doesn’t produce a clear and understandable code.
&lt;/div&gt;
&lt;div class=&quot;Unindented&quot;&gt;
We developped, at EONOS, a package to handle specific loop on arrays (or array like structures). You want to compute a columnwise standard deviation, on a rolling 50 rows window every 5 rows? This package is for you.
&lt;/div&gt;
&lt;div style=&quot;background-color: #cccccc; text-align: center;&quot;&gt;
&lt;blockquote class=&quot;Quote&quot;&gt;
This package will run a function on a bunch of subparts of a data-structure according to a specific pattern, with the possibility to remodel outputs into a convenient form.
&lt;/blockquote&gt;
&lt;/div&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




&amp;nbsp;&lt;/h2&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




1.1&amp;nbsp; Data structure
&lt;/h2&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Arrays, and matrices are convenient structures to store data. But lists are very useful too! The default authorized data-objects are arrays, and lists of (lists of (...)) arrays. Lets consider 2 simple data structures for the rest of this document:
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
let’s &lt;span class=&quot;formula&quot;&gt;&lt;i&gt;y&lt;/i&gt;&lt;/span&gt; be the list of 2 matrices &lt;span class=&quot;formula&quot;&gt;(10, 4)&lt;/span&gt; with dimnames described below:
&lt;/li&gt;
&lt;/ul&gt;
&lt;span class=&quot;posthidden&quot; id=&quot;&amp;lt;$article1_item$&amp;gt;1&quot;&gt;
&lt;/span&gt;
&lt;a href=&quot;javascript:expandcollapse(&#39;$article1_item1$&#39;)&quot;&gt;[+/-] show/hide this element&lt;/a&gt;
&lt;br /&gt;
&lt;pre class=&quot;LyX-Code&quot;&gt;&lt;span class=&quot;posthidden&quot; id=&quot;$article1_item1$&quot;&gt;
[[1]]        
       col_1 col_2 col_3 col_4 
row_1      1    11    21    31 
row_2      2    12    22    32 
row_3      3    13    23    33 
row_4      4    14    24    34 
row_5      5    15    25    35 
row_6      6    16    26    36 
row_7      7    17    27    37 
row_8      8    18    28    38 
row_9      9    19    29    39 
row_10    10    20    30    40

[[2]]        
       col_1 col_2 col_3 col_4 
row_1     -1   -11   -21   -31 
row_2     -2   -12   -22   -32 
row_3     -3   -13   -23   -33 
row_4     -4   -14   -24   -34 
row_5     -5   -15   -25   -35 
row_6     -6   -16   -26   -36 
row_7     -7   -17   -27   -37 
row_8     -8   -18   -28   -38 
row_9     -9   -19   -29   -39 
row_10   -10   -20   -30   -40
&lt;/span&gt;&lt;/pre&gt;
&lt;span class=&quot;posthidden&quot; id=&quot;$article1_item1$&quot;&gt;
&lt;/span&gt;


&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;span class=&quot;formula&quot;&gt;&lt;i&gt;x&lt;/i&gt;&lt;/span&gt; will be a simple matrix, the first part of &lt;span class=&quot;formula&quot;&gt;&lt;i&gt;y&lt;/i&gt;&lt;/span&gt; (&lt;span class=&quot;formula&quot;&gt;&lt;i&gt;x&lt;/i&gt; = &lt;i&gt;y&lt;/i&gt;[[1]]&lt;/span&gt;).
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




&amp;nbsp;&lt;/h2&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




1.2 The ’lambda’ function
&lt;/h2&gt;
&lt;div class=&quot;Unindented&quot;&gt;
The main function of this package is the function &lt;span class=&quot;formula&quot;&gt;&lt;i&gt;lambda&lt;/i&gt;&lt;/span&gt;. You call it this way:
&lt;/div&gt;
&lt;pre class=&quot;LyX-Code&quot;&gt;lambda( FUN, DATA, WAY, ... )
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Where FUN and DATA are obviously the function we want to apply and the data-structure we have, and WAY describes how we want to run through the data structure (DATA). Think of the ’apply’ function, you specify the subscripts the function will be applied over. The philosophy is the same here, you can set WAY=1, or WAY=c(1,2), except you can use more sophisticated arguments. 
&lt;/div&gt;
&lt;pre class=&quot;brush:python&quot;&gt;# note: ’lambda’, ’Idx’, ’win’ are part of the package.

# --- a colSums proxy ---
lambda( sum, x, 2 )

# --- a column-wise cumsum ---
# here we specify
# NULL for subscript 1 -&amp;gt; take all of them
#  Idx for subscript 2 -&amp;gt; use expanding windows
#     (i.e. all windows of the form [1:i])
lambda( sum, x, list(NULL,Idx) ) 

# --- a rolling colSums for 3-rows windows ---
#    (i.e. all windows of the form [i:(i+2)])
lambda( sum, x, win(3) )         
                                 
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
And a more complicated call, on &lt;span class=&quot;formula&quot;&gt;&lt;i&gt;y&lt;/i&gt;&lt;/span&gt;, summing pairs of numbers, from both matrices, placed at the same positions:
&lt;/div&gt;
&lt;pre class=&quot;brush:python&quot;&gt;lambda( sum, y, c(2,3) )
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
WAY argument can be a vector of integers (acting like the apply function), or a list of &lt;b&gt;iterators&lt;/b&gt;. An iterator is a function interpreting a data-structure, and a subscript (tte place of the iterator in the list), returning the way you should go through this dimension.
&lt;/div&gt;
&lt;h1 class=&quot;Section&quot;&gt;




&amp;nbsp;&lt;/h1&gt;
&lt;h1 class=&quot;Section&quot;&gt;




2 Iterators
&lt;/h1&gt;
&lt;div class=&quot;Unindented&quot;&gt;
When ’lambda’ is called on a data-structure, you need to specify the way you want to go through it. Specifically, you need to provide an iterator per dimension. Calling a sum over a 3-dimensional array needs 3 iterators, passed as a list argument. Here are the descriptions of availables iterators:&lt;/div&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




&amp;nbsp;&lt;/h2&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




2.1 Trivial (keyword: NULL)
&lt;/h2&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Default iterator, takes all the elements.
&lt;/div&gt;
&lt;pre class=&quot;brush:python&quot;&gt;lambda( sum, x, list(NULL,NULL) )
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
will return the sum of x elements.&lt;/div&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




&amp;nbsp;&lt;/h2&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




2.2 Atomic (keyword: dx)
&lt;/h2&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Consider every element apart.
&lt;/div&gt;
&lt;pre class=&quot;brush:python&quot;&gt;lambda( sum, x, list(dx,NULL) )
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
result:
&lt;/div&gt;
&lt;pre class=&quot;LyX-Code&quot;&gt;row_1  row_2  row_3  row_4  row_5  row_6  row_7  row_8  row_9 row_10      
   64     68     72     76     80     84     88     92     96    100 
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Because&lt;b&gt; dx&lt;/b&gt; is associated to the first subscript, and &lt;b&gt;NULL&lt;/b&gt; (trivial) to the second, will return a rowSums.
&lt;/div&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




&amp;nbsp;&lt;/h2&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




2.3 Rolling Windows (keyword: win)
&lt;/h2&gt;
&lt;div class=&quot;Unindented&quot;&gt;
This iterator needs an argument, the size of the window. Here is a sample call:
&lt;/div&gt;
&lt;pre class=&quot;brush:python&quot;&gt;lambda( sum, x, list(win(5), dx) )
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
result:
&lt;/div&gt;
&lt;pre class=&quot;LyX-Code&quot;&gt;      col_1 col_2 col_3 col_4 
row_1    NA    NA    NA    NA 
row_2    NA    NA    NA    NA 
row_3    NA    NA    NA    NA 
row_4    NA    NA    NA    NA 
row_5    15    65   115   165 
row_6    20    70   120   170 
row_7    25    75   125   175 
row_8    30    80   130   180 
row_9    35    85   135   185 
row_10   40    90   140   190
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
We want to roll our sum over rolling row-window of size 5, for each column (&lt;b&gt;dx&lt;/b&gt; at the second slot). 
&lt;/div&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




&amp;nbsp;&lt;/h2&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




2.4 Expanding Window (keyword: Idx)
&lt;/h2&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Windows take every element from first to current
&lt;/div&gt;
&lt;pre class=&quot;brush:python&quot;&gt;lambda( sum, x, list(Idx, dx) )
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
result:
&lt;/div&gt;
&lt;pre class=&quot;LyX-Code&quot;&gt;       col_1 col_2 col_3 col_4 
row_1      1    11    21    31 
row_2      3    23    43    63 
row_3      6    36    66    96 
row_4     10    50    90   130 
row_5     15    65   115   165 
row_6     21    81   141   201 
row_7     28    98   168   238 
row_8     36   116   196   276 
row_9     45   135   225   315 
row_10    55   155   255   355
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Will return a cumulative sum for each column (as apply( x, 2, cumsum ) )
&lt;/div&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




&amp;nbsp;&lt;/h2&gt;
&lt;h2 class=&quot;Subsection&quot;&gt;




2.5 All paths (keyword: ap)
&lt;/h2&gt;
&lt;div class=&quot;Unindented&quot;&gt;
Apply your function on every possible window of the chosen dimension
&lt;/div&gt;
&lt;pre class=&quot;brush:python&quot;&gt;lambda( sum, x, list(ap, dx) )
&lt;/pre&gt;
&lt;span class=&quot;posthidden&quot; id=&quot;&amp;lt;$article1_item$&amp;gt;2&quot;&gt;
&lt;/span&gt;
&lt;a href=&quot;javascript:expandcollapse(&#39;$article1_item2$&#39;)&quot;&gt;[+/-] show/hide the result&lt;/a&gt;
&lt;br /&gt;
&lt;pre class=&quot;LyX-Code&quot;&gt;&lt;span class=&quot;posthidden&quot; id=&quot;$article1_item2$&quot;&gt;
             col_1 col_2 col_3 col_4 
row_1 row_2      3    23    43    63 
row_1 row_3      6    36    66    96 
row_1 row_4     10    50    90   130 
row_1 row_5     15    65   115   165 
row_1 row_6     21    81   141   201 
row_1 row_7     28    98   168   238 
row_1 row_8     36   116   196   276 
row_1 row_9     45   135   225   315 
row_1 row_10    55   155   255   355 
row_2 row_3      5    25    45    65 
row_2 row_4      9    39    69    99 
row_2 row_5     14    54    94   134 
row_2 row_6     20    70   120   170 
row_2 row_7     27    87   147   207 
row_2 row_8     35   105   175   245 
row_2 row_9     44   124   204   284 
row_2 row_10    54   144   234   324 
row_3 row_4      7    27    47    67 
row_3 row_5     12    42    72   102 
row_3 row_6     18    58    98   138 
row_3 row_7     25    75   125   175 
row_3 row_8     33    93   153   213 
row_3 row_9     42   112   182   252 
row_3 row_10    52   132   212   292 
row_4 row_5      9    29    49    69 
row_4 row_6     15    45    75   105 
row_4 row_7     22    62   102   142 
row_4 row_8     30    80   130   180 
row_4 row_9     39    99   159   219 
row_4 row_10    49   119   189   259 
row_5 row_6     11    31    51    71 
row_5 row_7     18    48    78   108 
row_5 row_8     26    66   106   146 
row_5 row_9     35    85   135   185 
row_5 row_10    45   105   165   225 
row_6 row_7     13    33    53    73 
row_6 row_8     21    51    81   111 
row_6 row_9     30    70   110   150 
row_6 row_10    40    90   140   190 
row_7 row_8     15    35    55    75 
row_7 row_9     24    54    84   114 
row_7 row_10    34    74   114   154 
row_8 row_9     17    37    57    77 
row_8 row_10    27    57    87   117 
row_9 row_10    19    39    59    79 
&lt;/span&gt;&lt;/pre&gt;
&lt;span class=&quot;posthidden&quot; id=&quot;&amp;lt;$article1_item$&amp;gt;2&quot;&gt;
&lt;/span&gt;

&lt;br /&gt;
&lt;h1 class=&quot;Section&quot;&gt;




&amp;nbsp;&lt;/h1&gt;
&lt;h1 class=&quot;Section&quot;&gt;




3 Miscellanous
&lt;/h1&gt;
&lt;h2 class=&quot;Subsection-&quot;&gt;




&amp;nbsp;&lt;/h2&gt;
&lt;h2 class=&quot;Subsection-&quot;&gt;




Iterators argument Shortcuts
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
If you don’t specify all iterators, last missing ones will be replaced by NULL
&lt;/li&gt;
&lt;li&gt;
&lt;span class=&quot;formula&quot;&gt;&lt;i&gt;c&lt;/i&gt;(2, 3)&lt;/span&gt; passed as WAY argument will replicate &lt;span class=&quot;formula&quot;&gt;&lt;i&gt;list&lt;/i&gt;(&lt;i&gt;NULL&lt;/i&gt;, &lt;i&gt;dx&lt;/i&gt;, &lt;i&gt;dx&lt;/i&gt;)&lt;/span&gt;, and mimic ’apply’ call
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 class=&quot;Subsection-&quot;&gt;




&amp;nbsp;&lt;/h2&gt;
&lt;h2 class=&quot;Subsection-&quot;&gt;




Killing structure: struct
&lt;/h2&gt;
&lt;div class=&quot;Unindented&quot;&gt;
By default, Iterators doesn’t change the structure of DATA. A list of matrices will remain unchanged regardless of the WAY to iteratate over it. If you want to unlist/vectorialize intermediate data, just specify struct=FALSE when calling lambda.
&lt;/div&gt;
&lt;pre class=&quot;brush:python&quot;&gt;lambda( sum, y, c(2,3) )               # KO
lambda( sum, y, c(2,3), struct=FALSE ) # all good!
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
The first expression isolate every element on subscripts 2 and 3, letting extracted data structure as list[2 elmts] x matrix[1,1]. You can’t perform a sum on this structure, unless you unlist it. That’s what &lt;b&gt;struct&lt;/b&gt; parameter does. 
&lt;/div&gt;
&lt;h2 class=&quot;Subsection-&quot;&gt;




&amp;nbsp;&lt;/h2&gt;
&lt;h2 class=&quot;Subsection-&quot;&gt;




Understanding extractions
&lt;/h2&gt;
&lt;div class=&quot;Unindented&quot;&gt;
To dive deeper into underlying process, just try the following expression on your data:
&lt;/div&gt;
&lt;pre class=&quot;brush:python&quot;&gt;lambda( identity, DATA, WAY, simp=FALSE )
&lt;/pre&gt;
&lt;div class=&quot;Unindented&quot;&gt;
This call allow to visualize intermediate data-structures for a specific list of iterators.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #999999;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;hr class=&quot;footer&quot; style=&quot;color: #999999;&quot; /&gt;
&lt;div class=&quot;footer&quot; id=&quot;generated-by&quot;&gt;
&lt;span style=&quot;color: #999999;&quot;&gt;Document generated by &lt;/span&gt;&lt;a href=&quot;http://elyxer.nongnu.org/&quot; style=&quot;color: #999999;&quot;&gt;eLyXer 1.2.3 (2012-01-18)&lt;/a&gt;&lt;span class=&quot;create-date&quot;&gt;&lt;/span&gt;

&lt;/div&gt;</description><link>http://redrises.blogspot.com/2012/01/lambda-r-package-for-easier-iteration_18.html</link><author>noreply@blogger.com (Red Rise)</author><thr:total>0</thr:total></item></channel></rss>