This project has moved. For the latest updates, please go here.

Importing EPG Data form DVBViewer

Jan 16 at 8:35 AM
Hi,

i created a powershell script to Import DVBViewer EPG Data to MCEBuddy (actually convert the .TXT from DVBViewer INI to a NPVR compatible XML)

instructions below.

convert.ps1 // save it in e.g. c:\tools\convert.ps1
function Get-IniContent ($filePath)
{
    $ini = @{}
    switch -regex -file $FilePath
    {
        “^\[(.+)\]” # Section
        {
            $section = $matches[1]
            $ini[$section] = @{}
            $CommentCount = 0
        }
        “^(;.*)$” # Comment
        {
            $value = $matches[1]
            $CommentCount = $CommentCount + 1
            $name = “Comment” + $CommentCount
            $ini[$section][$name] = $value
        } 
        “(.+?)\s*=(.*)” # Key
        {
            $name,$value = $matches[1..2]
            $ini[$section][$name] = $value
        }
    }
    return $ini
}



foreach ($arg in $args) {
    Write-Host "Arg: $arg";

    $Filename = $arg

    $Nameonly = (Get-Item $Filename).DirectoryName+"\"+(Get-Item $Filename).Basename

    $myIni = Get-IniContent($Filename)

    $myIni["0"]


    # Set the File Name
    $filePath = $Nameonly+".XML"
 
    Write-Host "Output : " $filepath

    # Create The Document
    $XmlWriter = New-Object System.XMl.XmlTextWriter($filePath,$Null)
 
    # Set The Formatting
    $xmlWriter.Formatting = "Indented"
    $xmlWriter.Indentation = "4"
 
    # Write the XML Decleration
    $xmlWriter.WriteStartDocument()
 
    # Set the XSL
    $XSLPropText = "type='text/xsl' href='style.xsl'"
    $xmlWriter.WriteProcessingInstruction("xml-stylesheet", $XSLPropText)
 
    # Write Root Element
    $xmlWriter.WriteStartElement("recording")

    # Write the Document
    #$xmlWriter.WriteStartElement("Servers")

    $xmlWriter.WriteElementString("title",$myIni["0"]["Title"])
    if ($myIni["0"]["Info"].Equals(""))
    {
        $shortdesc= $myIni["0"]["Description"]
        $shortdesc= $shortdesc.Substring(0, $shortdesc.IndexOf(" ", 80))
        $xmlWriter.WriteElementString("subtitle",$shortdesc)
    }
    else
    {
        $xmlWriter.WriteElementString("subTitle",$myIni["0"]["Info"])
    }

    $xmlWriter.WriteElementString("description",$myIni["0"]["Description"])
    $xmlWriter.WriteElementString("channel",$myIni["Media"]["Channel"])
    $xmlWriter.WriteElementString("network",$myIni["Media"]["Channel"])



    # Write Close Tag for Root Element
    $xmlWriter.WriteEndElement # <-- Closing RootElement
 
    # End the XML Document
    $xmlWriter.WriteEndDocument()
 
    # Finish The Document
    $xmlWriter.Finalize
    $xmlWriter.Flush
    $xmlWriter.Close()

} # foreach arg
Modify a Profile to use the conversion in profiles.conf (mcebuddy onfig Directory)
C:\Program Files\MCEBuddy2x\config
PreMetaCustomCommandPath=C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
PreMetaCustomCommandParameters=-executionpolicy unrestricted -file c:\tools\convert.-ps1 ""%sourcefile%""
PreMetaCustomCommandHangPeriod=0 
PreMetaCustomCommandCritical=false 
PreMetaCustomCommandUISession=false 
PreMetaCustomCommandShowWindow=false 
PreMetaCustomCommandExitCodeCheck=false
good luck !
Marked as answer by rboy1 on 2/5/2017 at 2:43 PM