[WINDOWS] Plugin or script to update Third-Party SVN builds?

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
rimmi2002 Offline
Senior Member
Posts: 128
Joined: Jun 2008
Reputation: 0
Question  [WINDOWS] Plugin or script to update Third-Party SVN builds? Post: #1
Is there an script or plugin that can automatically update my XBMC with the new revs so I don't have to keep downloading the latest building and reinstalling them, Thanks.

Setup
XBMC Build 33619
ASUS M4A78-EM mobo
AMD X2 Regor 250 Processor
Integrated 780g HDMI graphics.
SP/DIF optical wire for sound
Win 7 Prof 640bit + Onkyo SR606 + Panasonic Viera 50" 720p
find quote
mpw222 Offline
Senior Member
Posts: 117
Joined: Mar 2008
Reputation: 0
Post: #2
I wrote a powershell script that does this for the jester builds. It needs to be run outside xbmc (it will close xbmc if running), and it requires .net 2 and powershell. I just have eventghost launch it. PM me if you're interested.
find quote
febox-pootz Offline
Junior Member
Posts: 38
Joined: Sep 2008
Reputation: 0
Post: #3
i'm interested too... can you send me please? thanks man
find quote
Livin Offline
Posting Freak
Posts: 3,433
Joined: May 2004
Reputation: 17
Location: above ground
Post: #4
mpw,
maybe you can post it and someone might be able to convert it to an XBMC script?

I'm not an expert but I play one at work.
find quote
kay.one Offline
Senior Member
Posts: 151
Joined: Dec 2006
Reputation: 3
Post: #5
could you please post the script on pastbin or even here so we can all use it,
find quote
mpw222 Offline
Senior Member
Posts: 117
Joined: Mar 2008
Reputation: 0
Post: #6
OK, here it is. I borrowed a wget function from a PowerShell repository, which is why it is written much better than the rest of the script. I'm definitely a scripting novice, so I encourage anyone to improve this or convert it to something that can be launched from inside xbmc.

What it does:
1. Downloads the html listing of jester's builds.
2. If a newer version is found (based on build number), the installer is downloaded. On the first run, it will always download the newest build.
3. The existing imdb scraper is preserved.
4. If xbmc is running, it gets closed.
5. New build installs silently.
6. Previous imdb scraper restored.
7. Build number written to ver.txt in xbmc directory.
8. XBMC starts in fullscreen.

How to run it:
1. Vista and XP only: Download Powershell 2 CTP3 (PowerShell 1.0 might work).
2. XP only: Download .NET 3.5 (2.0 might work)
3. Open a PowerShell prompt. In Vista/7, you'll need to run as an admin.
4. Run "set-executionpolicy remotesigned"
5. From here on, it can be run with powershell.exe <path>\update-xbmc.ps1 by an administrator.

Notes
1. Tested on XP, Vista and 7, x86 and x64. Running from a remote on Vista or 7 pretty much requires turning off UAC.

Code:
################################################################################​###
# Script:  Update-XBMC.ps1                                                        #
# Purpose: Update script for Jester Windows XBMC SVN builds.                      #
# Author:  mpw222, get-webfile function by Joel Bennett (http://poshcode.org/417) #
################################################################################​###

# Paramaters
param(
    [switch]$force,       # Forces installation of newest build
    [switch]$norestart,   # Does not restart xbmc
    [switch]$check,       # Performs version check only
    [switch]$help         # Prints usage
)


# User Defined
$xbmcurl="http://ocs.nl/xbmc/"


# Usage
if ($help) {
    "Update-XBMC.ps1 - An update script for Jester Windows XBMC SVN builds.`n"
    "Switches:"
    "-force        Forces installation of newest build"
    "-norestart    Does not restart xbmc"
    "-check        Performs version check only"
    "-help         Prints usage"
    exit 0
}


# Functions

###################################################
# Function: Get-WebFile                           #
# Purpose:  wget for PowerShell                   #
# Author:   Joel Bennett http://poshcode.org/417  #
###################################################

function Get-WebFile {
   param(
      $url = (Read-Host "The URL to download"),
      $fileName = $null,
      [switch]$Passthru,
      [switch]$quiet
   )
  
   $req = [System.Net.HttpWebRequest]::Create($url);
   $res = $req.GetResponse();

   if($fileName -and !(Split-Path $fileName)) {
      $fileName = Join-Path (Get-Location -PSProvider "FileSystem") $fileName
   }
   elseif((!$Passthru -and ($fileName -eq $null)) -or (($fileName -ne $null) -and (Test-Path -PathType "Container" $fileName)))
   {
      [string]$fileName = ([regex]'(?i)filename=(.*)$').Match( $res.Headers["Content-Disposition"] ).Groups[1].Value
      $fileName = $fileName.trim("\/""'")
      if(!$fileName) {
         $fileName = $res.ResponseUri.Segments[-1]
         $fileName = $fileName.trim("\/")
         if(!$fileName) {
            $fileName = Read-Host "Please provide a file name"
         }
         $fileName = $fileName.trim("\/")
         if(!([IO.FileInfo]$fileName).Extension) {
            $fileName = $fileName + "." + $res.ContentType.Split(";")[0].Split("/")[1]
         }
      }
      $fileName = Join-Path (Get-Location -PSProvider "FileSystem") $fileName
   }
   if($Passthru) {
      $encoding = [System.Text.Encoding]::GetEncoding( $res.CharacterSet )
      [string]$output = ""
   }

   if($res.StatusCode -eq 200) {
      [int]$goal = $res.ContentLength
      $reader = $res.GetResponseStream()
      if($fileName) {
         $writer = new-object System.IO.FileStream $fileName, "Create"
      }
      [byte[]]$buffer = new-object byte[] 4096
      [int]$total = [int]$count = 0
      do
      {
         $count = $reader.Read($buffer, 0, $buffer.Length);
         if($fileName) {
            $writer.Write($buffer, 0, $count);
         }
         if($Passthru){
            $output += $encoding.GetString($buffer,0,$count)
         } elseif(!$quiet) {
            $total += $count
            if($goal -gt 0) {
               Write-Progress "Downloading $url" "Saving $total of $goal" -id 0 -percentComplete (($total/$goal)*100)
            } else {
               Write-Progress "Downloading $url" "Saving $total bytes..." -id 0
            }
         }
      } while ($count -gt 0)
      
      $reader.Close()
      if($fileName) {
         $writer.Flush()
         $writer.Close()
      }
      if($Passthru){
         $output
      }
   }
   $res.Close();
}


#######################################################
# Function: Get-PFx86                                 #
# Purpose: Returns the 32-bit Program Files directory #
#######################################################

function Get-PFx86 {
    if ($env:processor_architecture -match "x86") {
        $pf=$env:programfiles
    } else {
        $pf=${env:ProgramFiles(x86)}
    }
    return $pf
}


########
# MAIN #
########

$lockfile=join-path $env:temp (($myinvocation.mycommand).tostring() + ".lock")

if (!$force) {
    if ((test-path $lockfile) -eq $true) {
        $lockage=((get-date) - ((dir $lockfile).lastwritetime)).hours
        if ($lockage -lt 1) {
            "Lock file detected, script closing"
            exit 1
        }
    }
}    

"lock" > $lockfile

if ((get-host).name -match "ConsoleHost") {"`n`n`n`n"}

$pf=Get-PFx86
$versionfile=Join-Path (Get-PFx86) "XBMC\ver.txt"

if (test-path $versionfile) {
    $currentversion=get-content $versionfile
    "XBMC SVN-$currentversion currently installed."
} else {
    $currentversion="0"
    "XBMC not installed or no version file."
}

$htmlfile=join-path $env:temp "xbmc.html"
Get-WebFile $xbmcurl $htmlfile
$link=get-content $htmlfile | select-string  "XBMCSetup-Rev\d+-jester.exe" | sort-object -descending | select-object -first 1
$newversion = ($link.tostring() -replace ".*href=`"XBMCSetup-Rev","") -replace "-jester`.exe.*",""
"XBMC SVN-$newversion available online."

if ($newversion -le $currentversion) {
    "Latest version already installed."    
    if ($force) {
        "Force switch detected, installing anyway."
    } else {
        "Script closing."
        remove-item $htmlfile
        Remove-Item $lockfile
        exit 0
    }
}

if ($check) {
    "Check switch enabled, script closing."
    Remove-Item $lockfile
    exit 0
}
    
$installerfile= ($link.tostring() -replace ".*XBMC","XBMC") -replace "`.exe.*","`.exe"
$installerlink=$xbmcurl + $installerfile
$installerpath=join-path $env:temp $installerfile
"Downloading XBMC SVN-$newversion."
Get-WebFile $installerlink $installerpath

$imdbfile=join-path $pf "XBMC\system\scrapers\video\imdb.xml"

if (test-path $imdbfile) {$imdbxml=get-content $imdbfile}

Get-Process | ? {$_.ProcessName -match "xbmc"} | Stop-Process
"Installing XBMC SVN-$newversion."
Start-Process $installerpath -wait -ArgumentList "/S"
"Installation complete, removing installer."
remove-item $installerpath
$newversion > $versionfile

if ($xbmcxml) {$imdbxml > $imdbfile}

if (!$norestart) {Start-Process (join-path $pf "XBMC\xbmc.exe") -ArgumentList "-fs"}

remove-item $htmlfile
remove-item $lockfile
exit 0
find quote
kricker Offline
Team-XBMC QA Specialist
Posts: 3,307
Joined: Apr 2004
Reputation: 16
Location: Knoxville, TN
Post: #7
If someone gets this working stable in a XBMC plugin like BigBellyBilly's XBMC T3CH updater script, I'll setup a ftp/http site for Ikons and myself to post our builds. Jester to if he likes, but it looks like he already has a good system in place for himself.

I was told once a long time ago by BigBellyBilly that he'd welcome someone to modify his script for such an endeavor.

Read this before using these builds.
XBMC win32 SVN builds
Changelog
(This post was last modified: 2009-03-22 06:28 by kricker.)
find quote
kay.one Offline
Senior Member
Posts: 151
Joined: Dec 2006
Reputation: 3
Post: #8
if you could upload your files to a simple html page, that could be parsed easily or even with an rrs feed i could modify this script to pick up any of the builds based on a parameter.
find quote
kricker Offline
Team-XBMC QA Specialist
Posts: 3,307
Joined: Apr 2004
Reputation: 16
Location: Knoxville, TN
Post: #9
PM me with directions on how you need it structured and we can start testing.

Read this before using these builds.
XBMC win32 SVN builds
Changelog
find quote
xexe Offline
Fan
Posts: 711
Joined: Sep 2008
Reputation: 1
Post: #10
Something worth considering in this excellent project is that each build exe should identify more than the vanilla build number.

Jesters format of:

XBMCSetup-Rev17788-jester-ext.exe

Is a good model to build upon. The main thing would be that if someone wanted say "the new Ikons with smoothvideo and HD tagging" if such a thing existed the filename contained that info.


Having problems getting your TV shows recognized?

Try my extra TV show matching REGEX here
find quote
Post Reply