Scripts for extracting data from nfo

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
akya Offline
Senior Member
Posts: 239
Joined: Feb 2012
Reputation: 1
Location: /home/akya
Post: #1
I wanted to share the scripts I wrote recently to extract data from movie and tvshow nfos. If you are a fan of spreadsheets, these scripts extract data from your collection to a text file which you can import into a good ol spreadsheet. You need python3 for executing the script.

For tvshow.nfo
Code:
https://gist.github.com/akyag/ca3649386550d30f81165745fbde9713

and for movie.nfo
Code:
https://gist.github.com/akyag/1205819121757d3eb7ffda062f707bc8

You need to edit the path to your collection. You get output like this for example -
title_rating_premiered_status_studio_genre_tags

Code:
8 Simple Rules_8.5_2002-09-14_Ended_ABC (US)_Comedy_
Arrested Development_9.3_2003-11-02_Ended_Netflix_Comedy_
Banshee_8.8_2013-01-11_Ended_Cinemax_Action, Adventure, Crime, Drama_MZABI, BluRay, x265, 720p
Battlestar Galactica_9.3_2003-12-08_Ended_SciFi_Action, Adventure, Drama, Science Fiction_
Breaking Bad_9.3_2008-01-17_Ended_AMC_Crime, Drama, Suspense, Thriller_Sparrow, BluRay, 720p

title_rating_year_runtime_genre_codec_tags

Code:
Once Upon a Time in the West_7.9_1968_166_Action, Western_Sergio Leone_h264 / AAC_YIFY
The Secret in Their Eyes_7.8_2009_129_Crime, Drama, Mystery, Romance_Juan José Campanella_h264 / AAC_anoXmous
The Silence of the Lambs_7.9_1991_118_Crime, Drama, Thriller_Jonathan Demme_h264 / AAC_YIFY
The Truman Show_7.7_1998_106_Comedy, Drama_Peter Weir_h264 / AAC_YIFY
The Usual Suspects_8.0_1995_106_Drama, Crime, Thriller_Bryan Singer_h264 / AAC_YIFY
WALL·E_7.7_2008_98_Animation, Family_Andrew Stanton_h264 / AAC_KiNGDOM - BRRip

The script took about 14 sec to extract data from 680 movies.

~Web and graphic designer... Linux enthusiast... Python Fan... A Gooner~
[AMD A10-7850K 3.7 Ghz, Radeon R7]
[Fedora 26]
[Kodi 17.3 (skin) Horizon]

find quote
hawikoeln Offline
Closed Account
Posts: 100
Joined: May 2016
Post: #2
Stupid question: Why not use the export function?

I write CSV files, that can be loaded in Excel, for my movies and shows within a second - without touching my library.


Movie template:

${foreach movies movie}"${movie.title}";"${movie.originalTitle}";"${movie.year}";"${movie.edition}";"${movie.director}";"${foreach movie.actors actor}${if index_actor=1}${actor.name},${end}${if index_actor=2}${actor.name},${end}${if index_actor=3}${actor.name},${end}${end}";"${movie.runtime}";"${movie.imdbId}";"${movie.tmdbId}";"${movie.top250}";"${movie.watched}";"${movie.dateAdded}";"${foreach movie.genres genre ,}${genre}${end}";"${foreach movie.tags tag ,}${tag}${end}";${foreach movie.videoFiles vf}"${vf.path}";"${vf.filename}";"${vf.filesize}";"${vf.containerFormat}";"${vf.videoCodec}";"${vf.videoWidth}";"${vf.videoHeight}";"${vf.audioCodec}";"${vf.audioChannels}";"${vf.duration}";${end}
${end}


Show template:

${foreach tvShows show}${foreach show.episodes episode}"${show.title}";"${show.year}";"${foreach show.tags tag ,}${tag}${end}";"${show.tvdbId}";"${show.watched}";"${episode.season}";"${episode.episode}";"${episode.title}";"${foreach episode.actors actor}${if index_actor=1}${actor.name},${end}${if index_actor=2}${actor.name},${end}${if index_actor=3}${actor.name},${end}${end}";"${episode.watched}";"${foreach episode.tags tag ,}${tag}${end}";${foreach episode.videoFiles vf}"${vf.path}";"${vf.filename}";"${vf.filesize}";"${vf.containerFormat}";"${vf.videoCodec}";"${vf.videoWidth}";"${vf.videoHeight}";"${vf.audioCodec}";"${vf.audioChannels}";"${vf.duration}"${end}
${end}${end}
find quote
akya Offline
Senior Member
Posts: 239
Joined: Feb 2012
Reputation: 1
Location: /home/akya
Post: #3
That's a nice way. I am learning python, so I just tried that. Now we have two different ways Smile

~Web and graphic designer... Linux enthusiast... Python Fan... A Gooner~
[AMD A10-7850K 3.7 Ghz, Radeon R7]
[Fedora 26]
[Kodi 17.3 (skin) Horizon]

find quote