Kodi Community Forum

Full Version: Export Video Library with IMDb url in .nfo
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello.
When exporting the Video Library to seperate files (as described here), it does include the IMDb id but not the full IMDb URL. How can I have this exported?
I would like to have the URL after the ending </movie> tag.
I don't want to use a third-party movie organizer ... have used too many of them ... I like to keep it simple ... Big Grin
Tia for any helpful answer ...
If you are using live or Linux you could get a bash script to do it. I am not the best but here are some tips of steps. I will work on it if I get time since I would like it to. If someone else does it faster post it since I may not have time.

1: Use something like
cd $baseofmoviedir
for i in `find . | grep .nfo`

1b: in that for do the rest

2: use grep on $i to find the line including "<id>tt" and save it to another variable

3: use sed on new variable to replace "<id>tt" with http://www.imdb.com/title/tt and "</id>" with nothing

4: echo $newvariable >> $i

Edit:
Ok I am working on it and have a working script as long no special characters like spaces exist in the file name or path. I will keep trying to figure it out.
Hey shadow! Thanks for jumping in ...
I'm on Mac and know my way around perl / regex scripts :-)

Would like to test your script ... oh and I hate spaces in filenames :-)
I just have a couple different for lines for testing how to get the full path and escape characters added, and the echo is to see if the variable is right. Which it isn't for any names with spaces. Unfortunately I got hundreds of movies from a guy that didn't use proper naming and I don't want to fix them.

Running this multiple times just keeps appending the imdb link multiple times and to clean it up after testing just export the library again and overwrite the old ones. Then only run it one time.



#!/bin/bash

export MOVIES=/home/xbmc/movies

cd $MOVIES
for i in `ls -1Rb | sed /^$/d | gawk '/:$/{dir=substr($0,1,length($0)-1)} !/:$/{printf "%s/%s\n",dir,$0}' | grep .nfo`
#for i in `find . -type f | sed 's/[!@\ "()]/\\&/g' | grep .nfo`
do
grep "<id>tt" '$i' | sed s/\ \ \ \ \<id\>tt/http:\\/\\/www.imdb.com\\/title\\/tt/ | sed s/\<\\/id\>// >> '$i'
echo $i
done


edit:
I found the commands used in the for lines on Google and don't understand them.
But I did make the much easier sed lines that actually modify the nfos
Had to 'macport' gawk first ... :-s
My movies get nicely listed up through the echo command but nfo files aren't modified ... dunnow why.
Will try and understand the commands first :-)
Thanks!

edit: the much easier sed command doesn't also work :-(
That is strange the sed commands work great for me maybe test with this one line manually using a test.nfo

grep "<id>tt" test.nfo | sed s/\ \ \ \ \<id\>tt/http:\\/\\/www.imdb.com\\/title\\/tt/ | sed s/\<\\/id\>// >> test.nfo

also try this to see if the url is made fine without modifying the nfo

grep "<id>tt" test.nfo | sed s/\ \ \ \ \<id\>tt/http:\\/\\/www.imdb.com\\/title\\/tt/ | sed s/\<\\/id\>//

*just to be sure you are not on low resolution and ended with extra newlines that should be one line and the for lines should be one each. I thought of that when I viewed the thread on my phone and they wrapped onto 2 lines each.

I don't know if any layout changes have happened to the nfo file since last release to git which I use so make sure when viewing the nfo in a text editor that four spaces exist before the <id> tag if not the script needs changed since I expect them to remove them.
The sed command works just perfectly on one file. The URL is made fine (nicely appended at the end of the nfo file), the <id> tag still has 4 empty spaces before it.
Only problem is the loop now ...
All my dirnames and filenames are like this:
Code:
X-Men.First.Class.2011.BluRay.1080p.DTS.x264-CHD
But I don't think that's a problem.
Will do some more 'try and error' Big Grin.
Try adding this before the for loop. I am on my phone at work so I can't.

IFS=$'\n'
I'm also at work now ... in a heavy fight with a stupid Windows server ...
Will pick this later up ...
Thx again!
D.
shadow Wrote:Try adding this before the for loop. I am on my phone at work so I can't.

IFS=$'\n'
Shadow, it is working!! Nod
This is the script which does it good now:

Code:
#!/bin/bash

export MOVIES=/Volumes/DATA/MOVIEZ

cd $MOVIES
#IFS=$'\n'
for i in `ls -1Rb | sed /^$/d | gawk '/:$/{dir=substr($0,1,length($0)-1)} !/:$/{printf "%s/%s\n",dir,$0}' | grep .nfo`
# for i in 'find . -type f | sed 's/[!@\ "()]/\\&/g' | grep .nfo"
do
grep "<id>tt" $i | sed s/\ \ \ \ \<id\>tt/http:\\/\\/www.imdb.com\\/title\\/tt/ | sed s/\<\\/id\>// >> $i
echo $i
done

Mark the $i which isn't between single quotes now Huh

Thank you very much for your help.
D.
That only worked for you since you don't have spaces but I finally got it to work and that IFS line was the biggest help since it made whole lines variables not space separated.
I even simplified the for line since I got rid of the escape characters and moved to just double quoting the variable.

Here is my final working script.

Code:
#!/bin/bash

MOVIES=/home/xbmc/movies
IFS=$'\n'

cd $MOVIES

for i in `find . -name '*.nfo' -exec echo "{}" \;`
do
grep "<id>tt" "$i" | sed s/\ \ \ \ \<id\>tt/http:\\/\\/www.imdb.com\\/title\\/tt/ | sed s/\<\\/id\>// >> "$i"
echo $i
done