Create a link to IMDb site for each movie, at movie's folder

All your suggestions, requests and ideas for future development
Post Reply
neriox
Posts: 18
Joined: 04 Feb 2013, 02:14

Create a link to IMDb site for each movie, at movie's folder

Post by neriox »

Hello,
I wonder if it is possible a new feature for the program.
The movie data are placed in the file .Nfo, which contains the code IMDb inclusive of each film.
I like to vote in the movies, and put them into lists, after seeing them.
It would be a very interesting feature where, after doing the fetch and rename the movie, it would create a file .lnk, a link pointing directly to the site of the movie on IMDb, because the link structure of IMDb is pretty simple.
Any questions I am available to exchange ideas.

Ty
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Create a link to IMDb site for each movie, at movie's fo

Post by rednoah »

I already put the imdb and TMDb links into the nfo file. Its a one-liner to go through all nfos and write the urls into extra files.


(writing code from the back of my head without any testing whatsoever)

Code: Select all

args.getFiles{ it.extension == 'nfo' }.each{
	it.xml.imdb.text.saveAs(new File(it.dir, 'imdb.url'))
}
:idea: Please read the FAQ and How to Request Help.
neriox
Posts: 18
Joined: 04 Feb 2013, 02:14

Re: Create a link to IMDb site for each movie, at movie's fo

Post by neriox »

Hello,
Thanks for the prompt reply.
However, I am very beginner ... How should I proceed to apply the above code? There is a way through the command line (Script .Bat)?
grateful
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Create a link to IMDb site for each movie, at movie's fo

Post by rednoah »

You'll have to make a text file (e.g. makeurls.groovy) and then copy & paste that piece of code. Then you'll need to open the cmdline and run it with filebot.

e.g.

Code: Select all

filebot -script makeurls.groovy /path/to/movies
:idea: Please read the FAQ and How to Request Help.
neriox
Posts: 18
Joined: 04 Feb 2013, 02:14

Re: Create a link to IMDb site for each movie, at movie's fo

Post by neriox »

Hello,
Thanks for the reply.
When I run thiscode:

Code: Select all

E:\Comp>filebot -script E:\Comp\makeurls.groovy E:\Comp\MovieFolder
this is the line that returns:

Code: Select all

MissingPropertyException: No such property: xml for class: java.io.File
Possible solutions: file, dir, name
groovy.lang.MissingPropertyException: No such property: xml for class: java.io.F
ile
Possible solutions: file, dir, name
        at Script3$_run_closure2.doCall(Script3.groovy:2)
        at Script3.run(Script3.groovy:1)
        at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
        at net.sourceforge.filebot.cli.ScriptShell.runScript(Unknown Source)
        at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)

        at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (░_░)
And the file the link is not created.
grateful
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Create a link to IMDb site for each movie, at movie's fo

Post by rednoah »

This should work:

Code: Select all

args.getFiles{ it.extension == 'nfo' }.each{ nfo ->
	def xml = nfo.text.xml
	['imdb', 'tmdb'].each{ db ->
		def url = xml."$db".text()
		if (url) {
			def urlFile = new File(nfo.dir, "${db}.url")
			def content = "[InternetShortcut]\nURL=${url}\n"
			println content.saveAs(urlFile)
		}
	}
}
EDIT: Updated the script to generate imdb and tmdb links.
:idea: Please read the FAQ and How to Request Help.
neriox
Posts: 18
Joined: 04 Feb 2013, 02:14

Re: Create a link to IMDb site for each movie, at movie's fo

Post by neriox »

Works like a charm!
Thank you!
neriox
Posts: 18
Joined: 04 Feb 2013, 02:14

Re: Create a link to IMDb site for each movie, at movie's fo

Post by neriox »

Hello,
I saw you updated the script postprocess of uTorrent with this idea, and added TMDB. I thought great. :)
hugs
maortal
Posts: 31
Joined: 16 Dec 2012, 11:18

Re: Create a link to IMDb site for each movie, at movie's fo

Post by maortal »

the imdb url file was abit broken atleast at my part... (in the htpc.groovy script)

the original line was

Code: Select all

		[[db:'imdb', id:movieInfo.imdbId, url:"http://www.imdb.com/title/tt{movieInfo.imdbId?.pad(7)}"], [db:'tmdb', id:movieInfo.id, url:"http://www.themoviedb.org/movie/${movieInfo.id}"]].each{
i replaced it and added ability to set custom icon for these shortcuts just set the icon folder and call the icons imdb.ico and tmdb.ico
so just replace these additional lines in the htpc.groovy file in the fetchMovieArtworkAndNfo function

Code: Select all

[[db:'imdb', id:movieInfo.imdbId, url:"http://www.imdb.com/title/tt" + (movieInfo.imdbId ?: 0).pad(7)], [db:'tmdb', id:movieInfo.id, url:"http://www.themoviedb.org/movie/${movieInfo.id}"]].each{
			if (it.id > 0) {
				location = "C:\\Program Files\\FileBot\\"
				def content = "[InternetShortcut]\nURL=${it.url}\nIconIndex=0\nIconFile=${location}${it.db}.ico"
				content.saveAs(new File(movieDir, "${it.db}.url"))
			}
		}
Last edited by maortal on 12 Feb 2013, 22:09, edited 1 time in total.
neriox
Posts: 18
Joined: 04 Feb 2013, 02:14

Re: Create a link to IMDb site for each movie, at movie's fo

Post by neriox »

Hello,
Nice Update.
In fact, I noticed that some links actually had a bug in imdb, but not in TVDB.
I've seen the new version and it was great!
Congratulations!
castortray
Posts: 4
Joined: 02 Mar 2015, 22:53

Re: Create a link to IMDb site for each movie, at movie's fo

Post by castortray »

Hi,
This is not working anymore for FileBot version 4.5.6 (r2818)
Can someone please help me ?

I found only http://filebot.net/scripts/artwork.tmdb.groovy but it's too much for me.
I need only links for IMDB and TMDB inside .nfo file.

Thanks in advance for help
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Create a link to IMDb site for each movie, at movie's fo

Post by rednoah »

The fn:artwork.tmdb will always create .nfo files, and that .nfo file will always contain a TheMovieDB and IMDb link.
:idea: Please read the FAQ and How to Request Help.
castortray
Posts: 4
Joined: 02 Mar 2015, 22:53

Re: Create a link to IMDb site for each movie, at movie's fo

Post by castortray »

but is there any way to remove everything from .nfo file except two lines:

Code: Select all

  <imdb id='tt0425743'>http://www.imdb.com/title/tt0425743</imdb>
  <tmdb id='41497'>http://www.themoviedb.org/movie/41497</tmdb>
castortray
Posts: 4
Joined: 02 Mar 2015, 22:53

Re: Create a link to IMDb site for each movie, at movie's fo

Post by castortray »

I've modified and merged two fiels htpc.groovy and artwork.tmdb.groovy
In results I created nfo.groovy script which create .nfo file which contains only IMDB and TMDB links

How to use:

Code: Select all

filebot -script nfo.groovy /path/to/movies
Source code of nfo.groovy

Code: Select all

import static groovy.json.StringEscapeUtils.*
 
def override = _args.conflict == 'override'

args.eachMediaFolder{ dir ->
	// fetch only missing artwork by default
	if (!override && dir.hasFile{it.name == 'movie.nfo'}) {
		println "Skipping $dir"
		return
	}
	
	def videos = dir.listFiles{ it.isVideo() } as List
	def query = _args.query
	def options = []
	
	if (query) {
		// manual search & sort by relevance
		options = TheMovieDB.searchMovie(query, _args.locale).sortBySimilarity(query, { it.name })
	} else if (videos?.size() > 0) {
		// run movie auto-detection for video files
		options = MediaDetection.detectMovie(videos[0], TheMovieDB, _args.locale, true)
	}
	
	if (options.isEmpty()) {
		println "$dir => movie not found"
		return
	}
	
	// auto-select movie
	def movie = options[0]
	
	// maybe require user input
	if (options.size() != 1 && !_args.nonStrict && !java.awt.GraphicsEnvironment.headless) {
		movie = javax.swing.JOptionPane.showInputDialog(null, 'Please select Movie:', dir.path, 3, null, options.toArray(), movie)
		if (movie == null) return null
	}
	
	println "$dir => $movie"
	try {
		fetchMovieArtworkAndNfo(dir, movie, dir.getFiles{ it.isVideo() }.sort{ it.length() }.reverse().findResult{ it }, true, override, _args.locale ?: Locale.ENGLISH)
	} catch(e) {
		println "${e.class.simpleName}: ${e.message}"
	}
}

def fetchMovieNfo(outputFile, movieInfo, movieFile, override) {
	def i = movieInfo
	def mi = tryLogCatch{ movieFile?.isFile() ? MediaInfo.snapshot(movieFile) : null }
	XML {
			imdb("http://www.imdb.com/title/tt" + (i.imdbId ?: 0).pad(7))
			tmdb("http://www.themoviedb.org/movie/${i.id}")
	}
	.saveAs(outputFile)
}

def fetchMovieArtworkAndNfo(movieDir, movie, movieFile = null, extras = false, override = false, locale = Locale.ENGLISH) {
	tryLogCatch {
		def movieInfo = TheMovieDB.getMovieInfo(movie, locale, true)

		// fetch nfo
		fetchMovieNfo(movieDir.resolve('movie.nfo'), movieInfo, movieFile, override)
	}
}
Currently .nfo file is saved as "movie.nfo".
I want to save is as movie_name.nfo, but I don't know how to do it.
Also how to get rid of XML style from this script ?

My knowledge of scripting is vere weak and I need your help.
Thanks in advance.
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Create a link to IMDb site for each movie, at movie's fo

Post by rednoah »

I wouldn't mess with the existing script. Just use my unmodified scripts, and then run your own very simple script that greps the links you want from movie.nfo and write it to your own file however you like.
:idea: Please read the FAQ and How to Request Help.
castortray
Posts: 4
Joined: 02 Mar 2015, 22:53

Re: Create a link to IMDb site for each movie, at movie's fo

Post by castortray »

rednoah wrote:I wouldn't mess with the existing script. Just use my unmodified scripts, and then run your own very simple script that greps the links you want from movie.nfo and write it to your own file however you like.
but I have no idea how to scripting :)
Based on my test I think that something shoul dbe change in this part of code
something with XML code and saveAs

Code: Select all

def fetchMovieNfo(outputFile, movieInfo, movieFile, override) {
   def i = movieInfo
   def mi = tryLogCatch{ movieFile?.isFile() ? MediaInfo.snapshot(movieFile) : null }
   XML {
         imdb("http://www.imdb.com/title/tt" + (i.imdbId ?: 0).pad(7))
         tmdb("http://www.themoviedb.org/movie/${i.id}")
   }
   .saveAs(outputFile)
}

def fetchMovieArtworkAndNfo(movieDir, movie, movieFile = null, extras = false, override = false, locale = Locale.ENGLISH) {
   tryLogCatch {
      def movieInfo = TheMovieDB.getMovieInfo(movie, locale, true)

      // fetch nfo
      fetchMovieNfo(movieDir.resolve('movie.nfo'), movieInfo, movieFile, override)
   }
}
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Create a link to IMDb site for each movie, at movie's folder

Post by rednoah »

Here's an example for using existing xattr metadata to generate URL / NFO files:
viewtopic.php?f=3&t=324

Code: Select all

filebot -script /path/to/xattr2url.groovy /path/to/input
xattr2url.groovy

Code: Select all

args.files.findAll{ it.video }.each {
	def link = getMediaInfo(it, "https://www.imdb.com/title/{imdbId}/")
	def file = getMediaInfo(it, "{folder}/[IMDb] {n}.url")

	println "$link => $file"
	link.saveAs(file)
}
:idea: Please read the FAQ and How to Request Help.
Post Reply