|
Author |
Message |
mikep
|
Post subject: Re: Automatically add your media to iTunes Posted: April 29th, 2016, 11:52 pm |
|
 |
DVD VOB |
Joined: November 4th, 2012, 4:15 am Posts: 98
|
Aquiva wrote: Hi Mike
Thanks again for this awesome script, it been workeing great for me. Unfortunately there is one hiccup, since most of the TV Episodes are coming out in mkv format, ffmpeg needs to convert them. The problem is that the sound is tinny (has a slight echo). Do you perhaps have some advise on the command line options I can use to fix this?
Thanks! Hi Aquiva I will check when I have some time but I may have adjusted the script for mkv just to "extract" the files, rather than converting them. I'll get back to you next week Regards Mike
|
|
|
|
 |
Aquiva
|
Post subject: Re: Automatically add your media to iTunes Posted: October 6th, 2016, 1:29 pm |
|
 |
Xvid Movie |
Joined: October 26th, 2015, 12:41 pm Posts: 32
|
Hi Mike
I have another issue and hope you can help me. I have added a new series to MCM (Lethal Weapon), the problem is the script does not inject the correct Meta Data and thus adds it to Itunes under "Home Movies" and also does not add the epsiode numbers etc.
Strangely it works fine with other Series already in Itunes (it just processed an episode of American Horror Story), so the script works.
I'm not sure if it is related to this specific series or the fact that it has not reference in Itunes yet (brand new series).
Any help would be greatly appreciated!
|
|
|
|
 |
mikep
|
Post subject: Re: Automatically add your media to iTunes Posted: October 7th, 2016, 1:37 am |
|
 |
DVD VOB |
Joined: November 4th, 2012, 4:15 am Posts: 98
|
Hi There
All the script does is inject the meta data that already exists in Media Center Master so that's where i would start checking.
Thanks
Mike
|
|
|
|
 |
Aquiva
|
Post subject: Re: Automatically add your media to iTunes Posted: October 7th, 2016, 5:39 am |
|
 |
Xvid Movie |
Joined: October 26th, 2015, 12:41 pm Posts: 32
|
That's the problem...The xml has all the info, but the script does not do the injection, although it does for other series' episodes. I also checked the file attributes and none are read-only. Is there a why I can run the script and see at what step the problem occurs?
Thanks!
|
|
|
|
 |
mikep
|
Post subject: Re: Automatically add your media to iTunes Posted: October 7th, 2016, 7:29 am |
|
 |
DVD VOB |
Joined: November 4th, 2012, 4:15 am Posts: 98
|
Hi I wish I knew how to step through the script. What you can do is look at the script and check. the script is called with the following parameters: - Enable TV Episode Post-Processing - %V %S %T %AD %ET %SE %EP %SE2 %EP2 %CR Check that Post processing in MCM is passing tyose parameters on to the script - in the Settings Post Processing. You can also read there what each of the parameters are .e.g. %S it the media Type - I think Then when you look at he script you will see that it picks up each of of the parameters and "does something" with it  Like: if LCase(WScript.Arguments(1)) = "episode" then ' check if TV show or Movie and set the media type theMediaType = "TV Show" else theMediaType = "Movie" end if Don't know if this help ? Regards Mike
|
|
|
|
 |
Aquiva
|
Post subject: Re: Automatically add your media to iTunes Posted: October 13th, 2016, 10:31 am |
|
 |
Xvid Movie |
Joined: October 26th, 2015, 12:41 pm Posts: 32
|
|
Hi Mike The symptoms is getting worse, more and more TV Episodes do not want to import correctly. For example Arrow S05E02: Log Output: 06:22 PM :: MCM: Post-processing running: 06:22 PM :: "C:\Program Files (x86)\Media Center Master\addToItunes.cmd" "H:\Series\Arrow\Season 5\Arrow - S05E02 - The Recruits.mp4" episode "Arrow" "2016-10-12" "The Recruits" 5 2 05 02So here I can see it is marked as an episode, but once the script runs, it is imported into Itunes under "Home Videos" and the only correct detail is the filename. The Script calling withing MCM is configured correctly. Here is the script, perhaps you can see something wrong: The only big change I made was the Remux MKV to Itunes section to "rename" mkv to mp4 instead of converting (it is much faster), the conversion works because the file plays. I don;t know if it is part of the problem, but the .bak files do not delete at the end either. Code: ' addToiTunes.vbs v1.2 - 21-11-2012 ' This script developed by Darren Blackley, Copyright 2012 - all rights reserved. ' You may use this script freely provided you leave this information in tact and complete.
' This script will check your media files and if compatiable inject itunes compatiable metadata ' in the the media and then add the file to iTunes (providing it is installed). If the media is ' not compatiable, it will convert the media to a m4v file and then process as outlined above.
' For this script to work, you will require the following free tools; ' HandbrakeCLI for windows - http://handbrake.fr/downloads2.php (to convert to m4v) ' AtomicParsley for Windows - https://bitbucket.org/jonhedgerows/atomicparsley/downloads (to inject the metadata directly) ' ' 5-04-2013 - Extension of the script to allow demuxing from mkv container to m4v container. ' Extension and demuxing of the mkv require the mkv to have h.264 and AC3 formats within the container, otherwise it will not work. ' added by Peter Remnemark 2013 ' Required free tool for the extension to work. ' ffmpeg for Windows - http://ffmpeg.zeranoe.com/builds/ (to mux mkv to m4v)
' MCM Variables for Post-Processing; ' - Enable Movie Post-Processing - %V %S %T %Y ' - Enable TV Episode Post-Processing - %V %S %T %AD %ET %SE %EP %SE2 %EP2
Option Explicit On Error Resume Next Dim objShell, objFSO, iTunesLibrary, xmlDoc, toolsPath, intReturn Dim Q2, theFile, theMediaType, theTitle, theAiredDate, theEpisodeTitle, theSeasonNum, theEpisodeNum, theSeasonNum2, theEpisodeNum2, theCoverArt, aCommand, theDescription, hCommand
' set the required variables for all. Set objShell = CreateObject("Wscript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") Set iTunesLibrary = WScript.CreateObject("iTunes.Application").LibraryPlaylist Set xmlDoc = CreateObject("Microsoft.XMLDOM") xmlDoc.async="false" Q2 = Chr(34)
' change this to suit where the tools are installed toolsPath = "C:\Program Files (x86)\Media Center Master\"
' the imput variables - from command line or MCM theFile = WScript.Arguments(0) ' get the absolute file path
if LCase(WScript.Arguments(1)) = "episode" then ' check if TV show or Movie and set the media type theMediaType = "TV Show" else theMediaType = "Movie" end if
theTitle = WScript.Arguments(2) ' set the media title
if theMediaType = "TV Show" then ' set aired date to right format for TV Show or Movie if WScript.Arguments(3) = "" then ' if no aired date - set to now... theAiredDate = Year(Now())&"-"& Month(Now())&"-"& Day(Now())&"T"& Hour(Now())&":"& Minute(Now()) else theAiredDate = WScript.Arguments(3) end if elseif theMediaType = "Movie" then if wscript.arguments(3) = "" then ' if no year - set to now... theAiredDate = Year(Now()) else theAiredDate = wscript.arguments(3) end if end if
theEpisodeTitle = WScript.Arguments(4) ' Set the TV Episode title theSeasonNum = WScript.Arguments(5) ' Set the single digit season number theEpisodeNum = WScript.Arguments(6) ' Set the single digit episode number theSeasonNum2 = WScript.Arguments(7) ' Set the two digit season number theEpisodeNum2 = WScript.Arguments(8) ' Set the two digit episode number theCoverArt = objFSO.GetParentFolderName(theFile) & "\folder.jpg" ' set the coverart
' Get the Movie synopis/Description from the title from movie.xml/<title>.nfo file if theMediaType = "Movie" then if objFSO.FileExists(objFSO.GetParentFolderName(theFile) & "\movie.xml") then xmlDoc.load(objFSO.GetParentFolderName(theFile) & "\movie.xml") theDescription = xmlDoc.GetElementsByTagName("Description").item(0).text elseif objFSO.FileExists(objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".nfo") then xmlDoc.load(objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".nfo") theDescription = xmlDoc.GetElementsByTagName("plot").item(0).text end if ' Get the TV Show synopis/Overview from the title from <title>.xml/<title>.nfo file elseif theMediaType = "TV Show" then if objFSO.FileExists(objFSO.GetParentFolderName(theFile) & "\metadata\" & objFSO.GetBaseName(theFile) & ".xml") then xmlDoc.load(objFSO.GetParentFolderName(theFile) & "\metadata\" & objFSO.GetBaseName(theFile) & ".xml") theDescription = xmlDoc.GetElementsByTagName("Overview").item(0).text elseif objFSO.FileExists(objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".nfo") then xmlDoc.load(objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".nfo") theDescription = xmlDoc.GetElementsByTagName("plot").item(0).text end If else theDescription = "No synopis found..." end if
' *** do the business! *** ' Check the file type and if not iTunes compatiable - process as required. if objFSO.FileExists(theFile) then if WScript.Arguments.length > 0 then if ((objFSO.GetExtensionName(theFile) = "mp4") or (objFSO.GetExtensionName(theFile) = "m4v")) then' call addMetadata iTunesLibrary.AddFile(theFile) elseif (objFSO.GetExtensionName(theFile) = "mkv") then' call muxFile call addMetadata iTunesLibrary.AddFile(theFile) else call convertFile call addMetadata iTunesLibrary.AddFile(theFile) end if else intReturn = objShell.Popup("No Media Filename Available - Nothing to add!" & chr(13) & chr(13) &"Correct Syntax to use: addToiTunes.vbs ""[path]<mediafilename>""",10,"No Media File Found!",64) 'automatically closes after 5 seconds end If else intReturn = objShell.Popup("Specified file does not exist!" & chr(13) & chr(13) & "Check: """ & theFile & """",10,"No File Found",16) 'automatically closes after 5 seconds end If
'intReturn = objShell.Popup("Operation Complete",5,"All Done!",64) 'automatically closes after 5 seconds wscript.quit ' *** end the business! ***
' inject the metadata for itunes function addMetadata aCommand = Q2 & toolsPath & "AtomicParsley.exe" & Q2 & " " & Q2 & theFile & Q2 & " --stik " & Q2 & theMediaType & Q2 ' set base command line
if theMediaType = "TV Show" then aCommand = aCommand & " --title " & Q2 & theEpisodeTitle & Q2 else aCommand = aCommand & " --title " & Q2 & theTitle & Q2 end if
if not theAiredDate = "" then ' add the aired date to command line aCommand = aCommand & " --year " & Q2 & theAiredDate & Q2 end if
if not theEpisodeTitle = "" then ' add the episode title to the command line (tv shows only) aCommand = aCommand & " --artist " & Q2 & theTitle & Q2 & " --TVShowName " & Q2 & theTitle & Q2 & " --albumArtist " & Q2 & theTitle & Q2 end if
if not theSeasonNum = "" then ' add the season number to command line (tv shows only) aCommand = aCommand & " --TVSeasonNum " & theSeasonNum & " --disk " & theSeasonNum end if
if not theEpisodeNum = "" then ' add the episode number to command line (tv shows only) aCommand = aCommand & " --TVEpisodeNum " & theEpisodeNum & " --tracknum " & theEpisodeNum end if
if not ((theSeasonNum2 = "") or (theEpisodeNum2 = "")) then ' add the season (two digit) and episode (two digit) numbers to command line (tv shows only) aCommand = aCommand & " --TVEpisode " & Q2 & theTitle & " - " & "S" & theSeasonNum2 & "E" & theEpisodeNum2 & " - " & theEpisodeTitle & Q2 end if
if not ((theTitle = "") or (theSeasonNum = "")) then ' add the season (two digit) and episode (two digit) numbers to command line (tv shows only) aCommand = aCommand & " --album " & Q2 & theTitle & ", Season " & theSeasonNum & Q2 end if
if objFSO.FileExists(objFSO.GetParentFolderName(theFile) & "\folder.jpg") then ' check for folder.jpg in the folder and if found add to command line aCommand = aCommand & " --artwork " & Q2 & objFSO.GetParentFolderName(theFile) & "\folder.jpg" & Q2 end if
aCommand = aCommand & " --description " & Q2 & Left(theDescription,250) & "..." & Q2 & " --longdesc " & Q2 & theDescription & Q2 ' add description to command line aCommand = aCommand & " --comment " & Q2 & "Details added " & Date() & " by addToiTunes " & Q2
aCommand = aCommand & " --overWrite" ' add overwrite media to command line (if not added will create new file)
objShell.Run aCommand,7,true 'wscript.echo aCommand end function
' convert to itunes compatiable universal format. function convertFile hCommand = Q2 & toolsPath & "handbrakecli.exe" & Q2 & " -i " & Q2 & theFile & Q2 & " -o " & Q2 & objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".mp4" & Q2 & " -e x264 -q 20.0 -a 1 -E faac -B 160 -6 dpl2 -R 48 -D 0.0 -f mp4 --strict-anamorphic -m ref=2:bframes=2:subme=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0" objShell.Run hCommand,7,true objFSO.MoveFile theFile, objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) &".bak" objFSO.DeleteFile theFile,true theFile = objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) &".mp4" end function
' mux mkv to itunes compatiable format (h.264 + acc 2ch + AC3). function muxFile 'ffmpeg -i theFile.mkv -strict experimental -vcodec copy -map 0:0 -map 0:1 -map 0:1 -c:1 libvo_aacenc -ac 2 -c:2 copy -sn output.mp4 hCommand = Q2 & toolsPath & "ffmpeg.exe" & Q2 & " -i " & Q2 & theFile & Q2 & " -c copy " & Q2 & objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".mp4" & Q2 'hCommand = Q2 & toolsPath & "ffmpeg.exe" & Q2 & " -i " & Q2 & theFile & Q2 & " -strict experimental -vcodec copy -map 0:0 -map 0:1 -map 0:1 -c:1 aac -ac 2 -c:2 copy -sn " & Q2 & objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".m4v" & Q2 objShell.Run hCommand,7,true objFSO.MoveFile theFile, objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) &".bak" objFSO.DeleteFile theFile,true theFile = objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) &".mp4" end function
|
|
|
|
 |
mikep
|
Post subject: Re: Automatically add your media to iTunes Posted: October 13th, 2016, 12:16 pm |
|
 |
DVD VOB |
Joined: November 4th, 2012, 4:15 am Posts: 98
|
Hi
My only guess would be that atomic parsley is not injecting (or not able to inject) the data into the file.
Maybe use a utility like MP3Tag to inspect the file to see what meta data, if any, is injected.
Also as an experiement use something like Xmedia recode to create the MP$ (you can "copy" the audio and video - no conversion) and then run it through the processor and see if it works - if it does then the problem is in you branch off to "elseif (objFSO.GetExtensionName(theFile) = "mkv") then' call muxFile "
Maybe also check your code (i'm on a mobile so s bit small) to make sure that the correct file name is passed to the addmetadata routine - maybe atomic parsley can't inject because the file name is wrong?
Anyway all I can think off for now.
Hope something helps
Regards
Mike
|
|
|
|
 |
Aquiva
|
Post subject: Re: Automatically add your media to iTunes Posted: October 13th, 2016, 12:25 pm |
|
 |
Xvid Movie |
Joined: October 26th, 2015, 12:41 pm Posts: 32
|
mikep wrote: Hi
My only guess would be that atomic parsley is not injecting (or not able to inject) the data into the file.
Maybe use a utility like MP3Tag to inspect the file to see what meta data, if any, is injected.
Also as an experiement use something like Xmedia recode to create the MP$ (you can "copy" the audio and video - no conversion) and then run it through the processor and see if it works - if it does then the problem is in you branch off to "elseif (objFSO.GetExtensionName(theFile) = "mkv") then' call muxFile "
Maybe also check your code (i'm on a mobile so s bit small) to make sure that the correct file name is passed to the addmetadata routine - maybe atomic parsley can't inject because the file name is wrong?
Anyway all I can think off for now.
Hope something helps
Regards
Mike Awesome, thanks for the fast reply Mike! I'll do as you suggested and give feedback next week.
|
|
|
|
 |
Aquiva
|
Post subject: Re: Automatically add your media to iTunes Posted: October 18th, 2016, 11:33 am |
|
 |
Xvid Movie |
Joined: October 26th, 2015, 12:41 pm Posts: 32
|
|
mikep wrote: Hi
My only guess would be that atomic parsley is not injecting (or not able to inject) the data into the file.
Maybe use a utility like MP3Tag to inspect the file to see what meta data, if any, is injected.
Also as an experiement use something like Xmedia recode to create the MP$ (you can "copy" the audio and video - no conversion) and then run it through the processor and see if it works - if it does then the problem is in you branch off to "elseif (objFSO.GetExtensionName(theFile) = "mkv") then' call muxFile "
Maybe also check your code (i'm on a mobile so s bit small) to make sure that the correct file name is passed to the addmetadata routine - maybe atomic parsley can't inject because the file name is wrong?
Anyway all I can think off for now.
Hope something helps
Regards
Mike Hi Mike OK I tried to find the problem, but I can't seem to find the issue. Today I added a new series (Westworld). The script ran perfectly for the 3 episodes (+ the latest Scoprion episode). Although Supergirl S02E02 is a no go. The conversion from MKV to MP4 works, as well the import into Itunes, but there is no metadata, so it isn't file correctly in Itunes. it is very strange that it works perfect for 4 episodes but certain episodes it doens work for at all. Some more info.... The first 2 episodes of Westworld were .mp4, and worked fine. The 3rd one was MK4 and was converted fine, but I had to manually kick off the "post processing" in MCM on that specific episode. The same goes for the Scorpion episode. Except for the manual run, it imported fine. The Supergirl episode was also MKV and was converted correctly, but it doesn't import correctly. I'll post the latest version of the script below, in case I changed something from the previous one... Thanks!
|
|
|
|
 |
Aquiva
|
Post subject: Re: Automatically add your media to iTunes Posted: October 18th, 2016, 11:33 am |
|
 |
Xvid Movie |
Joined: October 26th, 2015, 12:41 pm Posts: 32
|
|
Code: ' addToiTunes.vbs v1.2 - 21-11-2012 ' This script developed by Darren Blackley, Copyright 2012 - all rights reserved. ' You may use this script freely provided you leave this information in tact and complete.
' This script will check your media files and if compatiable inject itunes compatiable metadata ' in the the media and then add the file to iTunes (providing it is installed). If the media is ' not compatiable, it will convert the media to a m4v file and then process as outlined above.
' For this script to work, you will require the following free tools; ' HandbrakeCLI for windows - http://handbrake.fr/downloads2.php (to convert to m4v) ' AtomicParsley for Windows - https://bitbucket.org/jonhedgerows/atomicparsley/downloads (to inject the metadata directly) ' ' 5-04-2013 - Extension of the script to allow demuxing from mkv container to m4v container. ' Extension and demuxing of the mkv require the mkv to have h.264 and AC3 formats within the container, otherwise it will not work. ' added by Peter Remnemark 2013 ' Required free tool for the extension to work. ' ffmpeg for Windows - http://ffmpeg.zeranoe.com/builds/ (to mux mkv to m4v)
' MCM Variables for Post-Processing; ' - Enable Movie Post-Processing - %V %S %T %Y ' - Enable TV Episode Post-Processing - %V %S %T %AD %ET %SE %EP %SE2 %EP2
Option Explicit On Error Resume Next Dim objShell, objFSO, iTunesLibrary, xmlDoc, toolsPath, intReturn Dim Q2, theFile, theMediaType, theTitle, theAiredDate, theEpisodeTitle, theSeasonNum, theEpisodeNum, theSeasonNum2, theEpisodeNum2, theCoverArt, aCommand, theDescription, hCommand
' set the required variables for all. Set objShell = CreateObject("Wscript.Shell") Set objFSO = CreateObject("Scripting.FileSystemObject") Set iTunesLibrary = WScript.CreateObject("iTunes.Application").LibraryPlaylist Set xmlDoc = CreateObject("Microsoft.XMLDOM") xmlDoc.async="false" Q2 = Chr(34)
' change this to suit where the tools are installed toolsPath = "C:\Program Files (x86)\Media Center Master\"
' the imput variables - from command line or MCM theFile = WScript.Arguments(0) ' get the absolute file path
if LCase(WScript.Arguments(1)) = "episode" then ' check if TV show or Movie and set the media type theMediaType = "TV Show" else theMediaType = "Movie" end if
theTitle = WScript.Arguments(2) ' set the media title
if theMediaType = "TV Show" then ' set aired date to right format for TV Show or Movie if WScript.Arguments(3) = "" then ' if no aired date - set to now... theAiredDate = Year(Now())&"-"& Month(Now())&"-"& Day(Now())&"T"& Hour(Now())&":"& Minute(Now()) else theAiredDate = WScript.Arguments(3) end if elseif theMediaType = "Movie" then if wscript.arguments(3) = "" then ' if no year - set to now... theAiredDate = Year(Now()) else theAiredDate = wscript.arguments(3) end if end if
theEpisodeTitle = WScript.Arguments(4) ' Set the TV Episode title theSeasonNum = WScript.Arguments(5) ' Set the single digit season number theEpisodeNum = WScript.Arguments(6) ' Set the single digit episode number theSeasonNum2 = WScript.Arguments(7) ' Set the two digit season number theEpisodeNum2 = WScript.Arguments(8) ' Set the two digit episode number theCoverArt = objFSO.GetParentFolderName(theFile) & "\folder.jpg" ' set the coverart
' Get the Movie synopis/Description from the title from movie.xml/<title>.nfo file if theMediaType = "Movie" then if objFSO.FileExists(objFSO.GetParentFolderName(theFile) & "\movie.xml") then xmlDoc.load(objFSO.GetParentFolderName(theFile) & "\movie.xml") theDescription = xmlDoc.GetElementsByTagName("Description").item(0).text elseif objFSO.FileExists(objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".nfo") then xmlDoc.load(objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".nfo") theDescription = xmlDoc.GetElementsByTagName("plot").item(0).text end if ' Get the TV Show synopis/Overview from the title from <title>.xml/<title>.nfo file elseif theMediaType = "TV Show" then if objFSO.FileExists(objFSO.GetParentFolderName(theFile) & "\metadata\" & objFSO.GetBaseName(theFile) & ".xml") then xmlDoc.load(objFSO.GetParentFolderName(theFile) & "\metadata\" & objFSO.GetBaseName(theFile) & ".xml") theDescription = xmlDoc.GetElementsByTagName("Overview").item(0).text elseif objFSO.FileExists(objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".nfo") then xmlDoc.load(objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".nfo") theDescription = xmlDoc.GetElementsByTagName("plot").item(0).text end If else theDescription = "No synopis found..." end if
' *** do the business! *** ' Check the file type and if not iTunes compatiable - process as required. if objFSO.FileExists(theFile) then if WScript.Arguments.length > 0 then if ((objFSO.GetExtensionName(theFile) = "mp4") or (objFSO.GetExtensionName(theFile) = "m4v")) then' call addMetadata iTunesLibrary.AddFile(theFile) elseif (objFSO.GetExtensionName(theFile) = "mkv") then' call muxFile call addMetadata iTunesLibrary.AddFile(theFile) else ' call convertFile ' call addMetadata ' iTunesLibrary.AddFile(theFile) end if else intReturn = objShell.Popup("No Media Filename Available - Nothing to add!" & chr(13) & chr(13) &"Correct Syntax to use: addToiTunes.vbs ""[path]<mediafilename>""",10,"No Media File Found!",64) 'automatically closes after 5 seconds end If else intReturn = objShell.Popup("Specified file does not exist!" & chr(13) & chr(13) & "Check: """ & theFile & """",10,"No File Found",16) 'automatically closes after 5 seconds end If
'intReturn = objShell.Popup("Operation Complete",5,"All Done!",64) 'automatically closes after 5 seconds wscript.quit ' *** end the business! ***
' inject the metadata for itunes function addMetadata aCommand = Q2 & toolsPath & "AtomicParsley.exe" & Q2 & " " & Q2 & theFile & Q2 & " --stik " & Q2 & theMediaType & Q2 ' set base command line
if theMediaType = "TV Show" then aCommand = aCommand & " --title " & Q2 & theEpisodeTitle & Q2 else aCommand = aCommand & " --title " & Q2 & theTitle & Q2 end if
if not theAiredDate = "" then ' add the aired date to command line aCommand = aCommand & " --year " & Q2 & theAiredDate & Q2 end if
if not theEpisodeTitle = "" then ' add the episode title to the command line (tv shows only) aCommand = aCommand & " --artist " & Q2 & theTitle & Q2 & " --TVShowName " & Q2 & theTitle & Q2 & " --albumArtist " & Q2 & theTitle & Q2 end if
if not theSeasonNum = "" then ' add the season number to command line (tv shows only) aCommand = aCommand & " --TVSeasonNum " & theSeasonNum & " --disk " & theSeasonNum end if
if not theEpisodeNum = "" then ' add the episode number to command line (tv shows only) aCommand = aCommand & " --TVEpisodeNum " & theEpisodeNum & " --tracknum " & theEpisodeNum end if
if not ((theSeasonNum2 = "") or (theEpisodeNum2 = "")) then ' add the season (two digit) and episode (two digit) numbers to command line (tv shows only) aCommand = aCommand & " --TVEpisode " & Q2 & theTitle & " - " & "S" & theSeasonNum2 & "E" & theEpisodeNum2 & " - " & theEpisodeTitle & Q2 end if
if not ((theTitle = "") or (theSeasonNum = "")) then ' add the season (two digit) and episode (two digit) numbers to command line (tv shows only) aCommand = aCommand & " --album " & Q2 & theTitle & ", Season " & theSeasonNum & Q2 end if
if objFSO.FileExists(objFSO.GetParentFolderName(theFile) & "\folder.jpg") then ' check for folder.jpg in the folder and if found add to command line aCommand = aCommand & " --artwork " & Q2 & objFSO.GetParentFolderName(theFile) & "\folder.jpg" & Q2 end if
aCommand = aCommand & " --description " & Q2 & Left(theDescription,250) & "..." & Q2 & " --longdesc " & Q2 & theDescription & Q2 ' add description to command line aCommand = aCommand & " --comment " & Q2 & "Details added " & Date() & " by addToiTunes " & Q2
aCommand = aCommand & " --overWrite" ' add overwrite media to command line (if not added will create new file)
objShell.Run aCommand,7,true 'wscript.echo aCommand end function
' convert to itunes compatiable universal format. function convertFile hCommand = Q2 & toolsPath & "handbrakecli.exe" & Q2 & " -i " & Q2 & theFile & Q2 & " -o " & Q2 & objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".mp4" & Q2 & " -e x264 -q 20.0 -a 1 -E faac -B 160 -6 dpl2 -R 48 -D 0.0 -f mp4 --strict-anamorphic -m ref=2:bframes=2:subme=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0" objShell.Run hCommand,7,true objFSO.MoveFile theFile, objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) &".bak" objFSO.DeleteFile theFile,true theFile = objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) &".mp4" end function
' mux mkv to itunes compatiable format (h.264 + acc 2ch + AC3). function muxFile ' ffmpeg -i TheFile.mkv -strict experimental -vcodec copy -map 0:0 -map 0:1 -map 0:1 -c:1 libvo_aacenc -ac 2 -c:2 copy -sn output.mp4 ' hCommand = Q2 & toolsPath & "ffmpeg.exe" & Q2 & " -i " & Q2 & theFile & Q2 & " -strict experimental -vcodec copy -map 0:0 -map 0:1 -map 0:1 -c:1 aac -ac 2 -c:2 copy -sn " & Q2 & objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".mp4" & Q2 hCommand = Q2 & toolsPath & "ffmpeg.exe" & Q2 & " -i " & Q2 & theFile & Q2 & " -c copy " & Q2 & objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) & ".mp4" & Q2 objShell.Run hCommand,7,true objFSO.MoveFile theFile, objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) &".bak" objFSO.DeleteFile theFile,true theFile = objFSO.GetParentFolderName(theFile) & "\" & objFSO.GetBaseName(theFile) &".mp4" end function
|
|
|
|
 |
|
|