shell script to download recent recordings using getWizPnP -

Advanced Discussions on Programing for & Modifying Beyonwiz Products.

Moderators: Gully, peteru

Post Reply
steveb
Apprentice
Posts: 15
Joined: Mon Nov 15, 2010 19:23

shell script to download recent recordings using getWizPnP -

Post by steveb » Tue Apr 17, 2012 21:49

I'm trying to write unix shell script to download files to my unix box each night so I can view on other devices on my network. I only want to download recent files (I intend to delete anything on the unix box over say 2 weeks old) and don't want to waste time downloading stuff my seven year old has kept on the Beyonwiz for months.

I'm trying to use getWizPnP and pass it a file name or perl expression that will ensure I only transfer the recent files but I am having trouble figuring out what the native recording name format is, particularly the date stamp.
eg "getWizPnP.pl 2012" appears to get me a list of all the 2012 recordings.
"getWizPnP.pl apr" gets me stuff recorded in april, but as soon as I try "apr.15.2012" or "15.apr.2012" I get zip returned. Tried the usual date formats, used /, used spaces as separators - just cannot figure it.

I'm not too sure if the .'s aren't causing issues.
Anyone done this and got it working?
Anyone know what the date format is that getWizPnP operates on in the recording title?

prl
Wizard God
Posts: 32705
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Post by prl » Tue Apr 17, 2012 22:20

If you tell getWizPnP to download everything, it will only actually download things that aren't already in the destination folder.

It also has options to match on dates (but not on date ranges).

How to do both these things, (including the format of the dates to match against, and how to change that format) is in the Fine Manual :)

getWizPnP doesn't normally operate on the recording names with dates encoded in them, but you can see the encoding if you use --List. You can then fetch particular matches by using --BWName. But that's really doing things the hard way. The author of getWizPnP already decodes the date and time for you.

However, if you still want to do it yourself, the lines output by --List look like:
recordings/Minuscule Apr.13.2012_18.48
Which isn't all that hard to decode, but it is a bit tedious, especially if you want to calculate whether a recording lies in a date range.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

User avatar
Luke
Master
Posts: 298
Joined: Fri Jan 21, 2011 06:52
Location: Canberra

Post by Luke » Wed Apr 18, 2012 07:48

The date format you need to match is something like "Wed Apr 18 07:48:00 2012". The following example (using a bash shell) will download recordings for the current month:

Code: Select all

getWizPnP --regexp "$(date +%b.*%Y)"
A date range regex, i.e last two weeks, would be a lot harder to construct. I've never tried, as a regex is not the right tool for that. If you really want the last two weeks only, I'd use a programming language like python or perl and test dates extracted from the output of --List as prl suggests.

prl
Wizard God
Posts: 32705
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Post by prl » Wed Apr 18, 2012 11:16

Luke wrote:... A date range regex, i.e last two weeks, would be a lot harder to construct. I've never tried, as a regex is not the right tool for that. If you really want the last two weeks only, I'd use a programming language like python or perl and test dates extracted from the output of --List as prl suggests.
I wasn't really recommending using --List and --BWName for this. If a complete rolling archive is wanted, then using a "copy everything" command is probably the simplest way to implement it. It will produce some warning messages like:

Code: Select all

Recording <name> already exists
Use --force to overwrite it
Unfortunately, the date format selected with --dateFormat is not used in the match string for recording selection. Only the Unix-style date/time is used there. That is an important oversight and I will try to correct it in the next release.

Note that while getWizPnP allows you to copy recursively over subfolders on the Beyonwiz, the folder structure is flattened into a single folder on the destination. To copy the folder hierarchy properly, something like

Code: Select all

#!/bin/sh
dest=~/beyonwiz

for f in Recordings{,/Movies{,/Drama,/Comedy}}; do
    destfolder="$dest/$f"
    if [ ! -d "$destfolder" ]; then
        mkdir -p "destfolder"
    fi
    getWizPnP.pl --copy --resume --outDir="$destfolder" --folder="$f" ""
done
which is admittedly rather clunky, but does allow control over exactly which folders are archived. You could, for example, set up an Archive folder and only archive its contents, and move stuff into it by hand on the Beyonwiz for later archiving. The --resume option will ensure that if a copy was incomplete in a previous run (e.g. the recording was still being made), then the copy will be completed in the next run (only copying the parts of the recording not previously copied).

The above script should archive recordings in the following Beyonwiz folders:
Recordings
Recordings/Movies
Recordings/Movies/Drama
Recordings/Movies/Comedy
into corresponding folders on the host machine, under the beyonwiz folder in the user's home folder.

Running the script using crontab would fully automate the process.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

User avatar
grampus
Wizard
Posts: 1553
Joined: Sun Sep 16, 2007 07:16
Location: Williamstown Vic

Post by grampus » Wed Apr 18, 2012 14:16

Wish you two would stop talking dirty.
Makes it hard to concentrate.
:?
Screen: Panasonic TH-60ST60A; BeyonWiz U4; T3; Panasonic BD-35 Blu_Ray player

prl
Wizard God
Posts: 32705
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Post by prl » Wed Apr 18, 2012 15:01

Yep. All this naked bash code should probably be moved into Software Developers so as to not offend the sensibilities of other readers ;)
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

User avatar
Gully
Moderator
Posts: 7736
Joined: Thu Aug 30, 2007 22:08
Location: Melbourne

Post by Gully » Wed Apr 18, 2012 17:18

prl wrote:Yep. All this naked bash code should probably be moved into Software Developers so as to not offend the sensibilities of other readers ;)
Done.

I have pushed you into the dark back corner of the forum so nobody can hear you unless they go there on purpose. :D
Cheers
Gully
_____________
Beyonwiz U4
Logitech Harmony Elite
Google Pixel 6 Pro

steveb
Apprentice
Posts: 15
Joined: Mon Nov 15, 2010 19:23

Post by steveb » Wed Apr 18, 2012 19:41

Luke wrote:The date format you need to match is something like "Wed Apr 18 07:48:00 2012". The following example (using a bash shell) will download recordings for the current month:

Code: Select all

getWizPnP --regexp "$(date +%b.*%Y)"
.
That one works for me - thanks. What I am after is downloading say the last few days or the last month of recordings. I'll set this up in a CRON script to download (--noforce) all the recent recordings from the Beyonwiz to my Ubuntu server and also have some code that will delete anything over a month old. I didn't want to transfer everything as it takes a lot of time for the transfer and with the deleting of stuff over 30 days old on the Ubuntu box, I'd end up transferring a lot of files over and over again (as they may still be on the Beyonwiz but deleted off the Ubuntu server).

This then allows me (or my wife) to catch up on the latest episodes of various shows on other devices such as a tablet computer elsewhere in the house (eg while doing the regular torture on the exercise bike :?

prl
Wizard God
Posts: 32705
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Post by prl » Wed Apr 18, 2012 22:16

I still recommend using --resume in a script like this.
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

Post Reply

Return to “Software Developers”