[Tutorials] nfo xbmc or TMDB ➣ comment. txt

Frequently asked questions. Tutorials, tips and tricks.

[Tutorials] nfo xbmc or TMDB ➣ comment. txt

Unread postby rick » 09 Sep 2014, 18:58

sorry for my bad language

without using database
Image

1 I connect my server sshfs (fuse installed ...)

2 I use sshfs manager (windows) for connected to xbmc

3 scrapbook with plug https://www.themoviedb.org

4 I export the video file by mediateque, creation of files (nfo, poster, faniart) per file. nfo if a file exists in the folder it will delete

5 I created a script that starts every day (Cromb -e) to retrieve information from the nfo file to create a comment. txt, and converted the file poster cover


my first

#!/bin/bash
#path
cd /home/… /…

#convert remplaced cp
find . -name "*poster.jpg" | while read i ; do convert "${i%/*}/*poster.jpg" "${i%/*}/cover.jpg" ; done


find -type f -name "*.nfo" -print0 | while read -d $'\0' a; do


nfo=".nfo"
empty=""
slash="/"
singleQuote="'"
singleQuoteReplaced="'"
doubleQuote="""
youtube="plugin://plugin.video.youtube/?action=play_video&videoid="

base=${a/$nfo/$empty}
name=`cat "$a" | grep -i "<title>" | iconv -f utf-8 -t windows-1252//TRANSLIT`
original=`cat "$a" | grep -i "<originaltitle>" | iconv -f utf-8 -t windows-1252//TRANSLIT`
mpaa=`cat "$a" | grep -i "<mpaa>"`
genre=`cat "$a" | grep -i "<genre>" | iconv -f utf-8 -t windows-1252//TRANSLIT`
plot=`cat "$a" | grep -i "<plot>" | iconv -f utf-8 -t windows-1252//TRANSLIT`
actors=`cat "$a" | grep -i "<name>" | iconv -f utf-8 -t windows-1252//TRANSLIT`
director=`cat "$a" | grep -i "<director>" | iconv -f utf-8 -t windows-1252//TRANSLIT`
credits=`cat "$a" | grep -i "<credits>" | iconv -f utf-8 -t windows-1252//TRANSLIT`
country=`cat "$a" | grep -i "<country>" | iconv -f utf-8 -t windows-1252//TRANSLIT`


name=`echo $name | sed 's/<[^>]*[>]//g'`
name="${name#"${name%%[![:space:]]*}"}"
name="${name%"${name##*[![:space:]]}"}"
name=${name// : / }
name=${name// :/ }
name=${name//: / }
name=${name//:/ }
name=${name//$slash/$empty}
name=${name//$singleQuote/$singleQuoteReplaced}
name=${name//$doubleQuote/$singleQuoteReplaced}

year=`cat "$a" | grep -i "<year>" | sed 's/<[^>]*[>]//g'`
year=${year//[[:space:]]/}

original=`echo $original| sed 's/<[^>]*[>]//g'`
original=${original//$slash/$empty}
original=${original//$singleQuote/$singleQuoteReplaced}

country=`echo $country| sed 's/<[^>]*[>]//g'`
country=${country//[[:space:]]/}
country=${country//UnitedKingdom/Royaume-Uni}
country=${country//UnitedStatesofAmerica/États-Unis}
country=${country//Spain/Espagne}

mpaa=`echo $mpaa| sed 's/<[^>]*[>]//g'`
mpaa=${mpaa//*/Avertissement : des scènes, des propos ou des images peuvent heurter la sensibilité des spectateurs }

genre=`echo $genre| sed 's/<[^>]*[>]/./g'`
genre=${genre//$slash/$empty}
genre=${genre//$singleQuote/$singleQuoteReplaced}

rating=`cat "$a" | grep -i "<rating>" | sed 's/<[^>]*[>]//g'`
rating=`cat "$a" | grep -i "<rating>" | sed 's/\([0-9]*\.[0-9][0-9]\).*/\1/'`
rating=${rating//[[:space:]]/}
rating=${rating//<rating>/}

votes=`cat "$a" | grep -i "<votes>" | sed 's/<[^>]*[>]//g'`
votes=${votes//[[:space:]]/}

id=`cat "$a" | grep -i "<id>" | sed 's/<[^>]*[>]//g'`
id=${id//[[:space:]]/}

plot=`echo $plot| sed 's/<[^>]*[>]//g'`
plot=${plot//$slash/$empty}
plot=${plot//$singleQuote/$singleQuoteReplaced}
plot=${plot//$doubleQuote/$singleQuoteReplaced}

trailer=`cat "$a" | grep -i "<trailer>" | sed 's/<[^>]*[>]//g'`
trailer=${trailer//[[:space:]]/}
trailer=${trailer//$youtube/$empty}

actors=`echo $actors| sed 's/<[^>]*[>]/./g'`
actors=${actors//$singleQuote/$singleQuoteReplaced}

director=`echo $director| sed 's/<[^>]*[>]//g'`
director=${director//$singleQuote/$singleQuoteReplaced}

credits=`echo $credits| sed 's/<[^>]*[>]/./g'`
credits=${credits//$singleQuote/$singleQuoteReplaced}



if [ -f "${a%/*}/"comment.txt ]

then
echo "${a%/*}/"comment.txt "existant";

else
echo "~~Année:~~ __""$year""__ \\\ ~~Titre:~~ __""$name""__ \\\ ~~Titre Original:~~ __""$original""__ (""$country"") \\\ ~~Genre:~~ __""$genre""__ \\\ ~~Acteurs:~~ __""$actors""__ \\\ ~~Réalisateur:~~ __""$director""__ \\\ ~~Scénariste:~~ __""$credits""__ \\\ ~~Intérêt:~~ __""$rating"" (""$votes"" votes {link:www.themoviedb.org|https://www.themoviedb.org/search?query=""$id""} )__ / {link:recherche allocine.fr|http://www.allocine.fr/recherche/?q=""$original""} \\\\ ~~Résumé:~~ __""$mpaa""\\\ \\\\""$plot""__""\\\ {link:Bande annonce|http://www.youtube.com/embed/""$trailer""} \\\ \\\\""${a%/*}/" > "${a%/*}/"comment.txt;

fi

done
exit 0;

rick
 
Posts: 12
Joined: 29 Aug 2013, 21:43
Has thanked: 2 times
Been thanked: 5 times

Re: AW: [Tutorials] nfo xbmc ➣ comment. txt

Unread postby Madevil » 09 Sep 2014, 19:58

Thanks, excellent idea! :-)

Best regards
User avatar
Madevil
Administrator
Administrator
 
Posts: 913
Joined: 07 Dec 2012, 03:58
Has thanked: 1331 times
Been thanked: 952 times

Re: Re : [Tutorials] nfo xbmc ➣ comment. txt

Unread postby rick » 24 Oct 2014, 19:51

I changed my method
I create an ID file in the film
I put the id accent (eg 123456)
The bash is not clean but it can be adapted easily
#!/bin/bash
#script de recherche de film sur themoviedb TMDB
#folder
cd /home/.../.../Films

find -type f -name "ID" -print0 | while read -d $'\0' a; do
ID=`cat "$a"`

wget -O - -q https://www.themoviedb.org/movie/$ID/?language=fr > "${a%/*}/"themoviedb ;
mv "${a%/*}/"ID "${a%/*}/".ID

find -type f -name "themoviedb" -print0 | while read -d $'\0' b; do

empty=""
slash="/"
singleQuote="&#x27;"
singleQuoteReplaced="'"

cover=`cat "$b" | grep -i "image.tmdb.org/t/p/w500/" | sed 's/.*<meta property="og:image" content="//g' | sed 's/["/]*["> ]//g'`
original=`cat "$b" | sed -n '/<h3>Original Title.*/,/<h3>Movie Facts.*/{//d;p}' | sed 's/<p>//g' | sed 's/<.*//g'`
name=`cat "$b" | grep -i '<title>' | sed 's/<[^>]*[>]//g' | sed 's/&mdash; The Movie Database//g' | iconv -f utf-8 -t windows-1252//TRANSLIT`
trailer=`cat "$b" | grep -i 'www.youtube.com/watch?v=' | sed 's/" class=.*//g' | sed 's/.*<li><a id="//g'`
plot=`cat "$b" | grep -i '<meta name="description" content="' | sed 's/.*<meta name="description" content="//g' | sed 's/["/]*[">]//g' | iconv -f utf-8 -t windows-1252//TRANSLIT`
rating=`cat "$b" | grep -i '<span itemprop="ratingValue"' | sed 's/.*id="rating_hint">//g' | sed 's/<.*//g'`
votes=`cat "$b" | grep -i '<span itemprop="ratingValue"' | sed 's/.*p="ratingCount">//g' | sed 's/<.*//g'`
director=`cat "$b" | grep -i '<span itemprop="director"' | sed 's/.*itemprop="name">//g' | sed 's/<.*//g' | iconv -f utf-8 -t windows-1252//TRANSLIT`
credits=`cat "$b" | grep -i '<span itemprop="author"' | sed 's/.*itemprop="name">//g' | sed 's/<.*//g' | iconv -f utf-8 -t windows-1252//TRANSLIT`
actors=`cat "$b" | grep -i 'itemprop="actor"' | sed 's/.*itemprop="name">//g' | sed 's/<.*//g' | sed ':a;N;$!ba;s/\n/, /g' | iconv -f utf-8 -t windows-1252//TRANSLI`
genre=`cat "$b" | grep -i '<span itemprop="genre">' | sed 's/.*itemprop="genre">//g' | sed 's/<.*//g' | sed ':a;N;$!ba;s/\n/, /g' | iconv -f utf-8 -t windows-1252//TRANSLI`
budget=`cat "$b" | grep -i '<span id="budget' | sed 's/.*<span id="budget">//g' | sed 's/<.*//g'`


name=${name//$slash/$empty}
name=${name//$singleQuote/$singleQuoteReplaced}
original=${original//$slash/$empty}
original=${original//$singleQuote/$singleQuoteReplaced}
plot=${plot//$slash/$empty}
plot=${plot//$singleQuote/$singleQuoteReplaced}
director=${director//$singleQuote/$singleQuoteReplaced}
credits=${credits//$singleQuote/$singleQuoteReplaced}
actors=${actors//$singleQuote/$singleQuoteReplaced}
genre=${genre//$slash/$empty}
genre=${genre//$singleQuote/$singleQuoteReplaced}


if [$trailer = $empty];

then
youtube=$empty
else
youtube="\\\ {link:Bande annonce|http://www.youtube.com/embed/""$trailer"
fi


wget -c -O "${b%/*}/"cover.jpg --no-check-certificate "$cover"

echo "~~Titre:~~ __""$name""__ \\\ ~~Titre Original:~~ __""$original""__ \\\ ~~Genre:~~ __""$genre""__ \\\ ~~Acteurs:~~ __""$actors""__ \\\ ~~Réalisateur:~~ __""$director""__ \\\ ~~Scénariste:~~ __""$credits""__ \\\ ~~Budget:~~ __""$budget""__ \\\ ~~Intérêt:~~ __""$rating"" (""$votes"" votes {link:www.themoviedb.org|https://www.themoviedb.org/movie/""$ID""?language=fr} )__ / {link:recherche allocine.fr|http://www.allocine.fr/recherche/?q=""$original""} \\\\ ~~Résumé:~~ __""$mpaa""\\\ \\\\""$plot""__""$youtube""} \\\ \\\\""${b%/*}/" > "${b%/*}/"comment.txt;

rm "${b%/*}/"themoviedb
done
done
exit 0;
rick
 
Posts: 12
Joined: 29 Aug 2013, 21:43
Has thanked: 2 times
Been thanked: 5 times


Return to Info

Who is online

Users browsing this forum: No registered users and 2 guests