![]() |
Ant Movie Catalog (AMC) import script - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33) +--- Forum: Supplementary Tools for Kodi (https://forum.kodi.tv/forumdisplay.php?fid=116) +--- Thread: Ant Movie Catalog (AMC) import script (/showthread.php?tid=68252) |
Ant Movie Catalog (AMC) import script - jo_r - 2010-01-23 Bonjour, J'utilise Ant Movie Catalog pour cataloguer mes films (certains sont stockés sur un NAS et d'autres sur Dvd). Je ne connais pas Python et ai donc créé un script en vbs qui me permet d'importer mon catalogue Ant Movie Catalog au format xml dans XBMC. L'idéal serait de développer ce script en Python, voir d'utiliser une méthode de contournement du genre, exécuter le script vbs depuis un script Python. Ce script n'est pas 100% opérationnel, il n'est par exemple pas parfait pour l'import du nom des acteurs mais je n'en ai pas trouvé sur les forums... j'avance donc peu à peu. Ce script fonctionne correctement pour les films qui sont stockés sur un disque dur en local, MAIS pas sur le NAS. En local, tout fonctionne, mais je n'arrive pas à lire un film qui se trouve sur le NAS et la jaquette ne s'affiche pas. D'après ce que j'ai lu, il faudrait utiliser le chemin du CRC du fichier mais je ne sais pas comment m'y prendre. Pour les jaquettes, il y a plusieurs manières pour les gérer (en donnant le nom "folder.jpg" ou .nfo, etc). Bref, j'ai constaté en tous les cas qu'en local, je peux mettre tous mes films dans un répertoire ainsi que la jaquette (dans mon cas, la jaquette porte le nom du film) et ça fonctionne très bien. Ca fonctionne également si on stocke un film par répertoire. Si quelqu'un a une idée pour le faire fonctionner avec un NAS, ce serait super. Voici le script pour ceux que ça intéresse (attention, faites un test sur un catalogue, des fichiers vidéos et jaquettes au cas où). Pour info, dans Ant Movie Catalog, j'utilise le champ Url pour le chemin du fichier vidéo. Le script vbs génère un nouveau fichier xml (ne modifie donc pas votre fichier original) et il crée une sauvegarde du fichier xml original, par mesure de précaution. - jo_r - 2010-01-23 'Script qui génère depuis le fichier catalogue au format .xml un fichier .xml pour XBMC 'Prepare a regular expression object Set myRegExp = New RegExp myRegExp.IgnoreCase = True myRegExp.Global = True 'Variables strMoviesPath = "\\DISKSTATION\video\movies\" 'répertoire où sont stockés les films AMCCatalogFileXML = strMoviesPath & "_Catalogue.xml" 'chemin où se trouve le catalogue au format xml AMCCatalogFileXMLNew = strMoviesPath & "_Catalogue_XBMC.xml" 'chemin et nom du fichier qui sera généré et qui sera importé dans XBMC strPath = "http://192.168.2.20:50001/db/0/" 'en test 'si vous avez d'autres formats de fichiers, les ajouter ci-dessous et ne pas oublier d'agrandir le tableau myArray en conséquence Dim myArray(7) myArray(1) = "avi" myArray(2) = "mkv" myArray(3) = "divx" myArray(4) = "mpg" myArray(5) = "mpeg" myArray(6) = "wmv" myArray(7) = "mp4" If Right(strMoviesPath, 1) <> "\" Then strMoviesPath = strMoviesPath & "\" End If Const ForReading = 1 Const ForWriting = 2 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile _ (AMCCatalogFileXML, ForReading) Set objTextFileNew = objFSO.OpenTextFile _ (AMCCatalogFileXMLNew, ForWriting, True) '------------------------------------------------------------------- 'On fait une sauvegarde du fichier '------------------------------------------------------------------- If objFSO.FileExists(AMCCatalogFileXML) Then 'objFSO.CopyFile AMCCatalogFileXML, AMCCatalogFileXML & ".old" objFSO.CopyFile AMCCatalogFileXML, AMCCatalogFileXML & "." & TimeStamp() End If '------------------------------------------------------------------- 'On écrit les deux premières lignes du fichier xml '------------------------------------------------------------------- 'objTextFileNew.WriteLine "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes"" ?>" objTextFileNew.WriteLine "<?xml version=""1.0"" encoding=""iso-8859-1""?>" objTextFileNew.WriteLine "<videodb>" Do Until objTextFile.AtEndOfStream strNextLine = objTextFile.Readline '------------------------------------------------------------------- 'On récupère la valeur de tous les champs '------------------------------------------------------------------- 'Movie Number strMovieNumber = "" myRegExp.Pattern = "Movie Number=.*?""(.*?)""" 'myRegExp.Pattern = "Movie Number=.*?("".*?"")" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strMovieNumber = myMatch.SubMatches(0) Next Next 'Checked strChecked = "" myRegExp.Pattern = "Checked=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strChecked = myMatch.SubMatches(0) Next Next 'MediaType strMediaType = "" myRegExp.Pattern = "MediaType=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strMediaType = myMatch.SubMatches(0) Next Next 'Date strDate = "" myRegExp.Pattern = "Date=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strDate = myMatch.SubMatches(0) Next Next 'Rating strRating = "" myRegExp.Pattern = "Rating=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strRating = myMatch.SubMatches(0) Next Next 'OriginalTitle strOriginalTitle = "" myRegExp.Pattern = "OriginalTitle=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strOriginalTitle = myMatch.SubMatches(0) Next Next 'TranslatedTitle strTranslatedTitle = "" myRegExp.Pattern = "TranslatedTitle=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strTranslatedTitle = myMatch.SubMatches(0) Next Next 'FormattedTitle strFormattedTitle = "" myRegExp.Pattern = "FormattedTitle=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strFormattedTitle = myMatch.SubMatches(0) Next Next 'Director strDirector = "" myRegExp.Pattern = "Director=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strDirector = myMatch.SubMatches(0) Next Next 'Country strCountry = "" myRegExp.Pattern = "Country=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strCountry = myMatch.SubMatches(0) Next Next 'Category strCategory = "" myRegExp.Pattern = "Category=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strCategory = myMatch.SubMatches(0) Next Next 'Year strYear = "" myRegExp.Pattern = "Year=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strYear = myMatch.SubMatches(0) Next Next 'Length strLength = "" myRegExp.Pattern = "Length=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strLength = myMatch.SubMatches(0) Next Next 'Actors strActors = "" myRegExp.Pattern = "Actors=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strActors = myMatch.SubMatches(0) Next Next 'URL strURL = "" myRegExp.Pattern = "URL=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strURL = myMatch.SubMatches(0) Next Next 'Description strDescription = "" myRegExp.Pattern = "Description=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strDescription = myMatch.SubMatches(0) Next Next 'VideoFormat strVideoFormat = "" myRegExp.Pattern = "VideoFormat=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strVideoFormat = myMatch.SubMatches(0) Next Next 'VideoBitrate strVideoBitrate = "" myRegExp.Pattern = "VideoBitrate=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strVideoBitrate = myMatch.SubMatches(0) Next Next 'AudioFormat strAudioFormat = "" myRegExp.Pattern = "AudioFormat=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strAudioFormat = myMatch.SubMatches(0) Next Next 'AudioBitrate strAudioBitrate = "" myRegExp.Pattern = "AudioBitrate=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strAudioBitrate = myMatch.SubMatches(0) Next Next 'Resolution strResolution = "" myRegExp.Pattern = "Resolution=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strResolution = myMatch.SubMatches(0) Next Next strWidth = "" myRegExp.Pattern = "Resolution=.*?""(.*?)x" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strWidth = myMatch.SubMatches(0) Next Next strHeight = "" myRegExp.Pattern = "Resolution=.*?""*.x(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strHeight = myMatch.SubMatches(0) Next Next 'MsgBox "strHeight : " & strHeight 'Framerate strFramerate = "" myRegExp.Pattern = "Framerate=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strFramerate = myMatch.SubMatches(0) Next Next 'Languages strLanguages = "" myRegExp.Pattern = "Languages=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strLanguages = myMatch.SubMatches(0) Next Next 'Subtitles strSubtitles = "" myRegExp.Pattern = "Subtitles=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strSubtitles = myMatch.SubMatches(0) Next Next - jo_r - 2010-01-23 'SUITE 'Size strSize = "" myRegExp.Pattern = "Size=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strSize = myMatch.SubMatches(0) Next Next 'Disks strDisks = "" myRegExp.Pattern = "Disks=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strDisks = myMatch.SubMatches(0) Next Next 'Picture strPicture = "" myRegExp.Pattern = "Picture=.*?""(.*?)""" Set myMatches = myRegExp.Execute(strNextLine) For Each myMatch In myMatches For I = 0 To myMatch.SubMatches.Count - 1 strPicture = myMatch.SubMatches(0) Next Next wscript.echo "Film en cours de traitement : " & strMovieNumber & " - " & strOriginalTitle & " ..." If strMovieNumber <> "" Then '------------------------------------------------------------------- 'On recherche le film dans le répertoire If strOriginalTitle <> "" Then strURLNew = "" '''strChercheFilm = strOriginalTitle & ".*" '''Dim a: a = ListDir(strMoviesPath & strChercheFilm) '''Dim FileName '''For Each FileName In a '''Set File = objFSO.GetFile(FileName) '''strSize = File.Size \ 1024 \ 1024 '''If strSize > 20 Then 'Si le fichier fait plus de 200Mb... '''strURLNew = FileName '''End If '''Next FilmADouble = 0 For ext = 1 to UBound(MyArray) If objFSO.FileExists(strMoviesPath & strOriginalTitle & "." & myArray(ext)) Then strURLNew = strMoviesPath & strOriginalTitle & "." & myArray(ext) FilmADouble = FilmADouble + 1 End If Next If FilmADouble > 1 Then MsgBox "Attention, fichier vidéo " & strOriginalTitle & " à double !" End If End If End If If strMovieNumber <> "" Then objTextFileNew.WriteLine " <movie>" objTextFileNew.WriteLine " <title>" & strOriginalTitle & "</title>" objTextFileNew.WriteLine " <rating>" & strRating & "</rating>" objTextFileNew.WriteLine " <year>" & strYear & "</year>" '<top250></top250> '<votes></votes> objTextFileNew.WriteLine " <outline>" & strDescription & "</outline>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " <plot>" & strDescription & "</plot>" '<tagline></tagline> objTextFileNew.WriteLine " <runtime>" & strLength & " min</runtime>" '<mpaa></mpaa> '<playcount>0</playcount> '<lastplayed></lastplayed> '<file></file> objTextFileNew.WriteLine " <path>" & strPath & "</path>" If strURLNew <> "" Then objTextFileNew.WriteLine " <filenameandpath>" & strURLNew & "</filenameandpath>" else objTextFileNew.WriteLine " <filenameandpath>" & strMovieNumber & "</filenameandpath>" 'car visiblement si on a deux Urls identiques, problèmes lors de l'import End If 'objTextFileNew.WriteLine " <id>" & "xx00000001" & "</id>" objTextFileNew.WriteLine " <id>" & "xx0000000" & strMovieNumber & "</id>" 'PAS SUR QUE CA MARCHE (sinon faire for i = 1 to xxx, à la ligne 360 'If strMovieNumber <> "" Then') objTextFileNew.WriteLine " <genre>" & strCategory & "</genre>" '<set></set> '<credits></credits> objTextFileNew.WriteLine " <director>" & strDirector & "</director>" '<premiered></premiered> '<status></status> '<code></code> '<aired></aired> '<studio></studio> '<trailer></trailer> '<artist></artist> objTextFileNew.WriteLine " <originaltitle>" & strOriginalTitle & "</originaltitle>" objTextFileNew.WriteLine " <thumb>" & strMoviesPath & strPicture & "</thumb>" 'Ajouté le 05.01.2010 (à vérifier) 'MsgBox "Actors : " & strActors arrTest = SplitAdv(strActors) For x = 0 to Ubound(arrTest) objTextFileNew.WriteLine " <actor>" 'MsgBox "Each actor : " & arrTest(x) 'Suppression d'un espace s'il y en a un en début ou fin du nom If Left(arrTest(x),1) = " " Then arrTest(x) = Right(arrTest(x),Len(arrTest(x)) - 1) End If If Right(arrTest(x),1) = " " Then arrTest(x) = Left(arrTest(x),Len(arrTest(x)) - 1) End if objTextFileNew.WriteLine " <name>" & arrTest(x) & "</name>" 'objTextFileNew.WriteLine " <role>" & strMediaType & "</role>" objTextFileNew.WriteLine " </actor>" Next ' objTextFileNew.WriteLine " <actor>" ' objTextFileNew.WriteLine " <name>" & strActors & "</name>" ' objTextFileNew.WriteLine " <role>" & strMediaType & "</role>" ' objTextFileNew.WriteLine " </actor>" objTextFileNew.WriteLine " <fileinfo>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " <streamdetails>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " <video>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " <aspect>" & strMediaType & "</aspect>" 'Ajouté le 05.01.2010 (j'utilise ce champ pour savoir si c'est un dvd) objTextFileNew.WriteLine " <codec>" & strVideoFormat & "</codec>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " <width>" & strWidth & "</width>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " <height>" & strHeight & "</height>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " </video>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " <audio>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " <codec>" & strAudioFormat & "</codec>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " <language>" & strLanguages & "</language>" 'Ajouté le 05.01.2010 'objTextFileNew.WriteLine " <channels>" & str... & "</channels>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " </audio>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " <subtitle>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " <language>" & strSubtitles & "</language>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " </subtitle>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " </streamdetails>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " </fileinfo>" 'Ajouté le 05.01.2010 objTextFileNew.WriteLine " </movie>" End If Loop objTextFileNew.WriteLine "</videodb>" objTextFile.Close objTextFileNew.Close 'FONCTIONS '********* Function TimeStamp() 'On error resume Next madate = date & " " & formatDateTime(now(),4) texte = replace(madate," ", "") texte = replace(texte,".", "") texte = replace(texte,":", "") texte = replace(texte,"/", "") TimeStamp = texte End Function Function SplitAdv(strInput) Dim objRE Set objRE = CreateObject("VBScript.RegExp") objRE.IgnoreCase = True objRE.Global = true objRE.Pattern = ",(?=([^']*'[^']*')*(?![^']*'))" SplitAdv = Split(objRE.Replace(strInput, "\b"), "\b") End Function[/i] - amet - 2010-02-01 Please note that this is English ONLY forum. Consider yourself warned, it will not be tolerated. Zeljko - slash - 2010-02-01 Hi jo_r, You could post your question in french at passion-xbmc - paul - 2010-02-01 Amet Wrote:Please note that this is English ONLY forum.Well said you beat me to it just wish i knew what the hell they were talking about. Typical frogs ![]() - alda - 2010-02-01 Is possible explain it again in english ? I am also interested about data importing from ant movie catalog. Thanks Alda - Jucgshu - 2010-02-01 The main idea is a vbs script to import ant movie catalog catalogs. Works locally. Looks like it pretty much works - beside actor imports which could be not perfect. I'm too lazy to translate the whole thing but you got the idea. Yeah I know, another froggy frog. - paul - 2010-02-01 Jucgshu Wrote:The main idea is a vbs script to import ant movie catalog catalogs. Works locally. Looks like it pretty much works - beside actor imports which could be not perfect.Sorry if i offended you, at least you tried to explain it thanks |