Metadata Lookup Failures. Force rescan specified files only
Any film found with MetaData lookup errors will be moved from it's current location to <Film Drive>\Temp\Serviio\<subfolders> (Keeping your folder structure). With the films moved to a new folder Serviio will remove the films from the database (about an hour). Once the films have been removed from the database manually copy the films back to their original location to get Serviio to rescan Metadata for just these films.
When run the script will ask for the root path to your films.. IE x:\myfilms it uses this in conjunction with Serviio.log to identify series folders so it can keep the folder structure. Each film with a lookup error will be moved to <Film Drive>\temp\Serviio\<Sub Folders>
This script is designed to enable you to rescan just films which got metadata Errors, so you don't have to rescan all the files and maybe get lookup errors on other films.
Just copy the code into NotePad and save to c:\program files\Serviio_DLNA\Log\MetaDataFileMove.vbs (Must be in the same folder as Serviio.log)
- Code:
'**************************************
' MetaData Error File Move
'**************************************
' This script will move file with Metadata
' lookup errors out of the serviio folder
' and into \temp\serviio so they can be
' moved back to force Serviio to rescan
'**************************************
' Written By Mike Clayton
' Version 1.1
' **************************************
' 1.0 Original
' 1.1 Made script more generic for other people to use
'**************************************
On Error Resume Next
Dim WshShell,FSO,strFilmRoot,strFilmRootDrive
const ForReading =1
const ForWriting =2
Set WshShell = CreateObject("Wscript.shell")
Set fso = CreateObject ("scripting.filesystemobject")
GetFilmRoot() ' Get Root of movie dir (so Episodes can be copied)
CreateTempFolder() ' Create c:\temp\Serviio
' Open Serviio Log file
set Input= fso.openTextFile ("Serviio.log",ForReading , False)
IF Err.Number <> 0 Then
Wscript.echo "ERROR - Unable to open Serviio Log file"
Wscript.Quit
End If
Do while not Input.AtEndOfStream
strInput = Input.ReadLine
'Check if MetaData error Detected.
If Instr(1,strInput,"WARN [LibraryManager] Cannot read metadata",1) Then
'Chop off everything after the end of the film name
strInput = Left (strInput,Instr(strInput,"via extractor ONLINE_VIDEO_SOURCES") -1)
'Chop out the Film Name
strFileName = Mid (strInput, instrrev(strInput,"\") +1)
'Chop out the Film Path
strPath = Trim(Replace (UCase(Mid (strInput ,Instr(strInput,":\")-1)), Ucase(strFileName),""))
If strPath = strFilmRoot Then
' Film not an Episode
Err.Clear
fso.MoveFile strPath & strFileName , strFilmRootDrive & "\temp\serviio" & "\"
Else
' Episode not a Film
strSubFolder = Mid (strPath ,instrRev(strPath,"\",len(strPath)-1) +1)
If fso.FolderExists (strFilmRootDrive & "\temp\Serviio\" & strSubFolder) Then
'Temp Folder structure exists
Else
'Create subfolder (Episodes)
oFolder = fso.CreateFolder(strFilmRootDrive & "\temp\Serviio\" & strSubFolder)
End If
Err.Clear
fso.MoveFile strPath & strFileName , strFilmRootDrive & "\temp\serviio\" & strSubFolder
End If
IF Err.Number <> 0 Then
Wscript.echo "ERROR Film " & strFileName &" wasn't moved"
Err.Clear
End if
End If
Loop
strResponse = MsgBox ("All Done !." & vbcrlf & "Films with Metadata errors are now here " & vbcrlf & vbcrlf & _
strFilmRootDrive & "\Temp\Serviio" & vbcrlf & vbcrlf & "Wait for serviio to remove the files from the database" & vbcrlf & "and then Copy them back so Serviio will rescan them", _
VBOKOnly + VBInformation ,"All Done...")
' Create folder structure to move film to
Function CreateTempFolder()
On Error Resume Next
If fso.FolderExists (strFilmRootDrive & "\temp") Then
' C:\temp Exists
Else
Set oFolder = fso.CreateFolder (strFilmRootDrive & "\temp")
End IF
If fso.FolderExists (strFilmRootDrive & "\temp\Serviio") Then
' c:\temp\serviio Exists
Else
Set oFolder = fso.CreateFolder (strFilmRootDrive & "\temp\Serviio")
End IF
End Function
' Get full path to the film root folder
Function GetFilmRoot ()
On Error Resume Next
Do
strFilmRoot = UCase(Trim(InputBox ("Enter the full path to your Film Directory / Or Quit","Film Path",strFilmRoot))) &"\"
If strFilmRoot = "QUIT\" Then
Wscript.quit()
End If
IF mid(strFilmRoot,2,1) <> ":" Then
strReturn = MsgBox ("Please include the Drive letter in the path",VBOKOnly + VBCritical, "Error no Drive Letter")
strFilmRoot = "Invalid Path"
End If
If fso.FolderExists (strFilmRoot) Then
' Valid folder path entered
bValidDir = True
Else
' Invalid path entered. Loop to allow reenter
strReturn = MsgBox ("Unable to locate the directory you speicified ",VBOKOnly + VBCritical, "Invalid Path")
bValidDir = False
strFilmRoot = "Invalid Path"
End If
Loop until bValidDir
strFilmRootDrive = Left (strFilmRoot,2)
End Function