user-822
10-01-2015, 11:16 PM
After the recent fails created by the BB's changes, I started to look at what I could to get getiplayer working in the way I wanted again. I am quite pleased with how it is going, so thought id share here in case anyone else could find it useful..
Situation;
I wanted to download radio programs for a few programs regularly - most of these programmes are on going, so at present, I focus on about 5 each time. The PVR seems to have fallen apart for me (and I don't understand the makings of the app to be able to fix), but I have found that it still lets me download by PID - although the file is not named correctly - it just has the PID and some other characters. The metadata does come down though - that shows in the console window when it is processing.
I have come up with this script that does the following...
Runs a download for each series PID to pull down the files, saves the output from that to a text file
Reads the text file in to a variable as one string.
Goes through each file in my download directory that has a PID name and searches the metadata that saved in step one for a match.
When a match is found it renames the files and moves on to the next.
I have been quite surprised at how well this is working, so if you find yourself with similar requirements, you may be able to make use of it. Obviously the usual caution should be exercised when running this - please ensure you understand it before running it to avoid unexpected outcomes!
Apologies that this is not the best written script - if I get a chance I will tidy it up one day, just thought worth sharing
#set working dir to be location of get_iplayer.cmd
Set-Location 'C:\Program Files\get_iplayer'
#delete old metadata files (this empties all of temp)
Get-ChildItem c:\temp\ |Remove-Item
#run the getiplayer app against each series I want and dump output to a file
.\get_iplayer.cmd --pid b04830x1 --type radio --pid-recursive --modes=flashaacstd1,flashhigh,flashvhigh,rtsphigh,rtspvhigh | Out-File c:\temp\justso.log -append
.\get_iplayer.cmd --pid b006qy2s --type radio --pid-recursive --modes=flashaacstd1,flashhigh,flashvhigh,rtsphigh,rtspvhigh | Out-File c:\temp\15mindrama.log -append
.\get_iplayer.cmd --pid b006qtlx --type radio --pid-recursive --modes=flashaacstd1,flashhigh,flashvhigh,rtsphigh,rtspvhigh |Out-File c:\temp\batb.log -append
.\get_iplayer.cmd --pid b006qrzz --type radio --pid-recursive --modes=flashaacstd1,flashhigh,flashvhigh,rtsphigh,rtspvhigh |Out-File c:\temp\afternoon.log -append
.\get_iplayer.cmd --pid b01lyb82 --type radio --pid-recursive --modes=flashaacstd1,flashhigh,flashvhigh,rtsphigh,rtspvhigh |Out-File c:\temp\philoarms.log -append
#pull the output back from the file and in to a variable - minimise size by filtering on just the relevant lines
$15mindrama = (Get-Content C:\temp\15mindrama.log| ?{$_ -like '* episode *' -or $_ -like '* series:*'}| Out-String)
$afterNoon = (Get-Content C:\temp\afternoon.log| ?{$_ -like '* episode *' -or $_ -like '* series:*'}| Out-String)
$bedtime= (Get-Content C:\temp\batb.log| ?{$_ -like '* episode *' -or $_ -like '* series:*'}| Out-String)
$JustSo=(Get-Content C:\temp\JustSo.log| ?{$_ -like '* episode *' -or $_ -like '* series:*'}| Out-String)
$philoarms=(Get-Content C:\temp\philoarms.log| ?{$_ -like '* episode *' -or $_ -like '* series:*'}| Out-String)
#define the series to process that have been downloaded above
$progs = ("AfterNoon","15MinDrama","JustSo","PhiloArms","BedTime")
foreach($txt in $progs){
#go through each variable of series metadata
$metadata = Get-Variable -Name $txt -ValueOnly -ea Continue
if($metadata){
#if something is there....
get-childitem c:\iplayer -filter BBC_Ip* |foreach{
#iterate though each file in my holding area for downloads
$_.name -match "(?:BBC_iPlayer_Feeds_-_)(?<pid>[^_]+)" |Out-Null
#get any that have just the pid type of name
$pidf =$matches.pid
if($metadata -like "*$pidf*"){
"$pidf found in metadata: $txt"
#search for real name in metadata
$reg = "(?:.+Series:\s*?['<](?<ser>(?-s).*)['>])(?=.+Episode '(?<ep>.*)'\s\($pidf)"
$result = ([regex]::Match($metadata,$reg,@('SingleLine')))
$ser = $result.groups['ser'].value
$ep = $result.groups['ep'].value
#"$ser $ep"
if($result.groups['ser'].value){
#if found, rename the file
$newname = "$txt`_$(($ser).replace('?',''))_$(($ep).replace('?',''))$($_.Extension)" #changed added ext
$_ |Rename-Item -NewName $newname
$newname
}else{
write-error "$pidf found in metadata, but no series or episode identifid"
}
}else{
write-warning "$pidf not found in metadata: $txt"
}#end pid check
}#end file iteration
}#end metadata check (to see if it exists)
}#for loop.
Situation;
I wanted to download radio programs for a few programs regularly - most of these programmes are on going, so at present, I focus on about 5 each time. The PVR seems to have fallen apart for me (and I don't understand the makings of the app to be able to fix), but I have found that it still lets me download by PID - although the file is not named correctly - it just has the PID and some other characters. The metadata does come down though - that shows in the console window when it is processing.
I have come up with this script that does the following...
Runs a download for each series PID to pull down the files, saves the output from that to a text file
Reads the text file in to a variable as one string.
Goes through each file in my download directory that has a PID name and searches the metadata that saved in step one for a match.
When a match is found it renames the files and moves on to the next.
I have been quite surprised at how well this is working, so if you find yourself with similar requirements, you may be able to make use of it. Obviously the usual caution should be exercised when running this - please ensure you understand it before running it to avoid unexpected outcomes!
Apologies that this is not the best written script - if I get a chance I will tidy it up one day, just thought worth sharing
#set working dir to be location of get_iplayer.cmd
Set-Location 'C:\Program Files\get_iplayer'
#delete old metadata files (this empties all of temp)
Get-ChildItem c:\temp\ |Remove-Item
#run the getiplayer app against each series I want and dump output to a file
.\get_iplayer.cmd --pid b04830x1 --type radio --pid-recursive --modes=flashaacstd1,flashhigh,flashvhigh,rtsphigh,rtspvhigh | Out-File c:\temp\justso.log -append
.\get_iplayer.cmd --pid b006qy2s --type radio --pid-recursive --modes=flashaacstd1,flashhigh,flashvhigh,rtsphigh,rtspvhigh | Out-File c:\temp\15mindrama.log -append
.\get_iplayer.cmd --pid b006qtlx --type radio --pid-recursive --modes=flashaacstd1,flashhigh,flashvhigh,rtsphigh,rtspvhigh |Out-File c:\temp\batb.log -append
.\get_iplayer.cmd --pid b006qrzz --type radio --pid-recursive --modes=flashaacstd1,flashhigh,flashvhigh,rtsphigh,rtspvhigh |Out-File c:\temp\afternoon.log -append
.\get_iplayer.cmd --pid b01lyb82 --type radio --pid-recursive --modes=flashaacstd1,flashhigh,flashvhigh,rtsphigh,rtspvhigh |Out-File c:\temp\philoarms.log -append
#pull the output back from the file and in to a variable - minimise size by filtering on just the relevant lines
$15mindrama = (Get-Content C:\temp\15mindrama.log| ?{$_ -like '* episode *' -or $_ -like '* series:*'}| Out-String)
$afterNoon = (Get-Content C:\temp\afternoon.log| ?{$_ -like '* episode *' -or $_ -like '* series:*'}| Out-String)
$bedtime= (Get-Content C:\temp\batb.log| ?{$_ -like '* episode *' -or $_ -like '* series:*'}| Out-String)
$JustSo=(Get-Content C:\temp\JustSo.log| ?{$_ -like '* episode *' -or $_ -like '* series:*'}| Out-String)
$philoarms=(Get-Content C:\temp\philoarms.log| ?{$_ -like '* episode *' -or $_ -like '* series:*'}| Out-String)
#define the series to process that have been downloaded above
$progs = ("AfterNoon","15MinDrama","JustSo","PhiloArms","BedTime")
foreach($txt in $progs){
#go through each variable of series metadata
$metadata = Get-Variable -Name $txt -ValueOnly -ea Continue
if($metadata){
#if something is there....
get-childitem c:\iplayer -filter BBC_Ip* |foreach{
#iterate though each file in my holding area for downloads
$_.name -match "(?:BBC_iPlayer_Feeds_-_)(?<pid>[^_]+)" |Out-Null
#get any that have just the pid type of name
$pidf =$matches.pid
if($metadata -like "*$pidf*"){
"$pidf found in metadata: $txt"
#search for real name in metadata
$reg = "(?:.+Series:\s*?['<](?<ser>(?-s).*)['>])(?=.+Episode '(?<ep>.*)'\s\($pidf)"
$result = ([regex]::Match($metadata,$reg,@('SingleLine')))
$ser = $result.groups['ser'].value
$ep = $result.groups['ep'].value
#"$ser $ep"
if($result.groups['ser'].value){
#if found, rename the file
$newname = "$txt`_$(($ser).replace('?',''))_$(($ep).replace('?',''))$($_.Extension)" #changed added ext
$_ |Rename-Item -NewName $newname
$newname
}else{
write-error "$pidf found in metadata, but no series or episode identifid"
}
}else{
write-warning "$pidf not found in metadata: $txt"
}#end pid check
}#end file iteration
}#end metadata check (to see if it exists)
}#for loop.