xbox-scene.com - your xbox news information source
Quick Links: Main Forums | Xbox360 Forums | Xbox1 Forums | PS3 Forums
Xbox-Scene Forum Help  Search Xbox-Scene Forums   Xbox-Scene Forum Members   Xbox-Scene Calendar

Giganews Usenet Offers: +1150 days binary retention, 99%+ Completion, and Unlimited Speed/Access!

360 ODD Emulators: X360 Key $99 | Wasabi360 FAT $99 | Wasabi360 Slim $99
C4E's iXtreme Burner MAX Drive: LiteOn iHAS124 DROPPED TO JUST $17


Welcome Guest ( Log In | Register )

 Forum Rules Rules
 
Reply to this topicStart new topic
> Music Video Nfo Creator, vbscript to create XBMC compatble nfo files for your music videos
craigey
post Dec 19 2007, 05:59 PM
Post #1


X-S Member
*

Group: Members
Posts: 90
Joined: 23-August 04
Member No.: 140985



Hi all,

I was having a few issues with my music videos. XBMC only picked up about 80 of them. I had another 200 (or so) that I would need to create nfo files for so that XBMC could add them to the library.

Anyway to make my life easier I did it via a vbscript. Just thought I'd share it with you all. (I make no apologies for the sloppy coding. It works, so who cares)!

CODE


'*  This script creates an XBMC Music Video Nfo file based on the artist & trackname. *
'*  The videos must be in the format artist - trackname for this to work.            *
'*  Mpg, Avi, Wmv, Swf, M2v & Flv files will be picked up.  If there is a format     *
'*  I've missed, line 34 can be edited to add the additional extension. Just add     *
'*  or lcase(exten) = ".xxx" before the word then.                          *
'*  The script is currently unble to handle any 4 letter extensions such as .mpeg    *
'*                                               *
'*  (C)Craigey2007 - 19-12-2007.  Use at your own risk.   V1.6                       *


i = 0
f = 0
g = 0
log_name = "music_video_nfo_creator.log"

Set sa = CreateObject("Shell.Application")
set oF = sa.BrowseForFolder(0, "Source Folder:", ssfWINDOWS)
if (not oF is nothing) then
set fi = oF.Items.Item
else
wscript.quit
end if

Set filesys = CreateObject("Scripting.fileSystemObject")
Set sourceFolder = filesys.GetFolder(fi.Path)     ' The folder containing your Music Videos

set mvidslist = sourceFolder.files
startTime = Timer

For Each mvids in mvidslist
    trackName = mvids.name
exten = right(mvids,4)
if lcase(exten) = ".avi" or lcase(exten) = ".wmv" or lcase(exten) = ".mpg" or lcase(exten) = ".swf" or lcase(exten) = ".m2v" or lcase(exten) = "flv" then
i=i+1
  str1=trackname

fullfilename = WScript.ScriptFullName
currentFolder = Left(filename, InstrRev(filename, "\"))

Set FSOd = CreateObject("Scripting.FileSystemObject")
Set logFile = FSOd.OpenTextFile(currentfolder+log_name, 8, True)

on error resume next
    seperator = InstrRev(str1,"-") 'count left to the first occurance of "-"
    if (seperator >= 1) then                'if the seperator exists split into artist and song
        artist = Left(str1,seperator)              'seperate artist
        songLength= (Len(str1)- seperator)          'work out chr length of song
        song = right(str1,songLength)              'seperate song
        strArtist = artist
        strSong = song
        strSong = Replace(strSong,exten,"")
        strArtist = trim(strArtist)
        strSong = trim(strSong)
        noArtist = Len(strArtist)    'if it can't find an artist name, replace with 'Unknown'
                
    if noArtist = "0" then
        strArtist = "Unknown"
    end if
     noSong = Len(strSong)            'if it can't find a song name, replace with 'Unknown'
        if noSong = "0" then                            
            strSong = "Unknown"
        end if
    else                    'leave alone
    strArtist = "Unknown"
    end if    

str1 = replace(str1,exten,"")
destfil = sourceFolder+"\"+str1+".nfo"



if filesys.FileExists(destFil) then
g=g+1
logFile.Writeline "INFO:**********************Duplicate Below*************************"
else
f=f+1
Set fsonfo = CreateObject("Scripting.FileSystemObject")
Set nfoFile = FSOnfo.OpenTextFile(destfil, 8, True)
nfoFile.Writeline "<musicvideo>"
nfoFile.Writeline "<title>"&strSong&"</title>"
nfoFile.Writeline "<artist>"&strArtist&"</artist>"
nfoFile.Writeline "<album></album>"
nfoFile.Writeline "<genre></genre>"
nfoFile.Writeline "<runtime></runtime>"
nfoFile.Writeline "<plot></plot>"
nfoFile.Writeline "<year></year>"
nfoFile.Writeline "<director></director>"
nfoFile.Writeline "<studio></studio>"
nfoFile.Writeline "</musicvideo>"
nfoFile.Close
set fsonfo = nothing
set nfofile = nothing
end if

timesecs = Timer - startTime
logFile.Writeline trackname & "        " & str1 & "        " & destfil & "        " & g & "        " & f & "        " & i & "        " &timesecs
logFile.Close

end if
next



elapsedTimesecs = Timer - startTime
elapsedtimesecs = CInt(elapsedtimesecs)


if i = "0" then
ermsg="No Music Videos were Found."
erTitle="Files not Found"
MsgBox erMsg, vbOkOnly + vbExclamation, erTitle
wscript.quit
end if

days=0
hours=0
mins=0

do while elapsedtimesecs > 59
mins=mins+1
elapsedtimesecs = elapsedtimesecs - 60
loop

do while mins > 59
hours=hours+1
mins = mins - 60
loop

do while hours > 24
days=days+1
hours = hours - 24
loop

timetaken = f & " Music Videos Nfo files created in "
if days > 1 then
timetaken = timetaken & days & " Days & "
end if
if days = 1 then
timetaken = timetaken & days & " Day & "
end if
if hours > 1 then
timetaken = timetaken & hours & " Hours & "
end if
if days <> 1 and hours = 1 then
timetaken = timetaken & hours & " Hour & "
end if
if mins > 1 then
timetaken = timetaken & mins & " Minutes & "
end if
if hours <> 1 and mins = 1 then
timetaken = timetaken & mins & " Minute & "
end if
if elapsedtimesecs <> 1 then
timetaken = timetaken & elapsedTimesecs & " Seconds"
end if
if elapsedtimesecs = 1 then
timetaken = timetaken & elapsedTimesecs & " Second"
end if

if g = 1 then
timetaken = timetaken & vbcrlf & g & " NFO File already existed & was ignored"
elseif g > 1 then
timetaken = timetaken & vbcrlf & g & " NFO Files already existed & were ignored"
end if

set FSOd = Nothing
set logFile = Nothing

msgbox(timetaken)


This post has been edited by craigey: Dec 19 2007, 06:02 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
dgm
post Dec 21 2007, 01:03 PM
Post #2


X-S Enthusiast


Group: Members
Posts: 12
Joined: 2-September 07
Member No.: 354521



Hi

Nice script, but you need to change is slightly.

QUOTE(craigey @ Dec 19 2007, 05:35 PM) *


CODE


        artist = Left(str1,seperator)              'seperate artist
    



CODE


        artist = Left(str1,seperator-2)              'seperate artist
    


add "-2" to remove the " -" from the Artist name.

Doug
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
craigey
post Dec 21 2007, 04:54 PM
Post #3


X-S Member
*

Group: Members
Posts: 90
Joined: 23-August 04
Member No.: 140985



QUOTE(dgm @ Dec 21 2007, 02:39 PM) *

Hi

Nice script, but you need to change is slightly.
CODE


        artist = Left(str1,seperator-2)              'seperate artist
    


add "-2" to remove the " -" from the Artist name.

Doug


It depends on the format of your vides. I did mention in the top of the comments that it'd work for files with the filename format of Artist - trackname.xxx

Could you post an example of the filename format that the -2 would work for. I presume it'd be something like album - artist - track?

Anyway thanks for taking the time to comment. :-)
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
dgm
post Dec 21 2007, 05:33 PM
Post #4


X-S Enthusiast


Group: Members
Posts: 12
Joined: 2-September 07
Member No.: 354521



Hi

The Police - Every Little Thing She Does Is Magic.avi

Gives with the unmodified script:

CODE

<musicvideo>
<title>Every Little Thing She Does Is Magic</title>
<artist>The Police -</artist>
<album></album>
<genre></genre>
<runtime></runtime>
<plot></plot>
<year></year>
<director></director>
<studio></studio>
</musicvideo>


And with the modified line:

CODE

<musicvideo>
<title>Every Little Thing She Does Is Magic</title>
<artist>The Police</artist>
<album></album>
<genre></genre>
<runtime></runtime>
<plot></plot>
<year></year>
<director></director>
<studio></studio>
</musicvideo>


The only difference is <artist> </artist>

Doug
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
craigey
post Dec 21 2007, 11:15 PM
Post #5


X-S Member
*

Group: Members
Posts: 90
Joined: 23-August 04
Member No.: 140985



Bum!
Yep Thanks for that.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
craigey
post Dec 21 2007, 11:38 PM
Post #6


X-S Member
*

Group: Members
Posts: 90
Joined: 23-August 04
Member No.: 140985



Just in case anyone has run the script (like me) & ended up with "artist -" in the nfo files. You can use the following script to fix it. (Hopefully I wont need to post another script to fix this one)!!

CODE

Const ForReading = 1
Const ForWriting = 2

Set sa = CreateObject("Shell.Application")
set oF = sa.BrowseForFolder(0, "Source Folder:", ssfWINDOWS)
if (not oF is nothing) then
set fi = oF.Items.Item
else
wscript.quit
end if

Set filesys = CreateObject("Scripting.fileSystemObject")
Set Path = filesys.GetFolder(fi.Path)     ' The folder containing your Music Videos


Set objFSO = CreateObject("Scripting.FileSystemObject")

Set FSO = CreateObject("Scripting.FileSystemObject")

ScanDirectory FSO.GetFolder(path)

Sub ScanDirectory(oFolder)
    ScanFiles oFolder

    For each folder in oFolder.SubFolders
        ScanDirectory folder
    Next
End Sub

Sub Scanfiles(oFolder)

    For each file in oFolder.Files

extens = right(file,4)

if lcase(extens) = ".nfo" then

Set objFile = objFSO.OpenTextFile(file, ForReading)

strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, " -", "")
strNewText = Trim(strNewText)
If strNewText <> StrText Then
Set objFile = objFSO.OpenTextFile(file, ForWriting)
objFile.WriteLine strNewText
objFile.Close
end if

end if
    Next
End Sub

Msgbox("Done")
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
bionic1234
post Jan 8 2008, 05:23 AM
Post #7


X-S Enthusiast


Group: Members
Posts: 2
Joined: 31-July 07
Member No.: 350909



Very cool craigey, thanks for sharing.
I am a newbie to using VBscripts, so I looked around a while and then figured out how to do it, for anyone else out there looking to use this awesome VBscript.
I used PrimalScript 2007 (as I first tried just copying and pasting the code to Notepad and saving as a .wsf file - but Windows Scripting Host didn't seem to like something in the code.
So I copied and pasted craigey's original VBscript into PrimalScript 2007.
Step1 Create a Project
Step2 Create a Data - Script file in that Project file
Step3 Copy and paste craigey's code into the data file (making the modification to the artist line of course)
Step4 Save
Step5 Run Active Project

Thanks again craigey

User is offlineProfile CardPM
Go to the top of the page
+Quote Post





Reply to this topicStart new topic

 

Lo-Fi Version Time is now: 20th May 2013 - 08:46 AM