Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: Command wich transfer the Marked Filename for VDR ?



Axel,

I use such a function, too. I created some scripts for converting VDR files
into Divx, burning to CD and so on. For that I extended VDR to start up to 9
different scripts from the recordings menu by pressing the buttons 1-9. The
0-Key is reserved for a help function, but not yet implemented. Perhaps a
smilar extension could be integrated into VDR. It's really nice to start
actions like converting files, burning and so on with a "one-button-click"
from your remote control.

My modification applies to v0.96 which I'm still using. If there are not
much changes in this area, this should work with the current versions of
VDR. Because of the older version I'll supply no patchfile but plain code.

Changes in menu.c:

new function: (you have to change the path to your video-dir, this could be
solved more cleaner, but this was a quick'n'dirty solution)

--- schnipp -------------------------------------------------------
eOSState cMenuRecordings::ExecuteScript(eKeys Key)  // RJR
{
  char msg[256];

  sprintf(msg, "Execute script %d?", Key-k0);

  if (Interface->Confirm(tr(msg))) {
    cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
    char *cmd_result = NULL;  delete cmd_result;
    char *command = NULL;     delete command;

    command = (char*)malloc( strlen(ri->recording->FileName()) + 12 +
strlen("/dvb/video/video0/recordings_script_n") );
    sprintf(command, "/dvb/video/video0/recordings_script_%d %s", Key-k0,
ri->recording->FileName());

    cmd_result = NULL;
    FILE *p = popen(command, "r");
    if (p) {
      int l = 0;
      int c;
      while ((c = fgetc(p)) != EOF) {
        if (l % 20 == 0)
          cmd_result = (char *)realloc(cmd_result, l + 21);
        cmd_result[l++] = c;
      }
      if (cmd_result)
        cmd_result[l] = 0;
      pclose(p);
    }
    else
      esyslog(LOG_ERR, "ERROR: can't open pipe for command '%s'", command);
  }

  return osContinue;
}
--- schnapp -------------------------------------------------------

changed function:

--- schnipp -------------------------------------------------------
eOSState cMenuRecordings::ProcessKey(eKeys Key)
{
  switch (Key) {                                    // RJR
    case k1 ... k9: return ExecuteScript(Key);      // RJR
    default:        break;                          // RJR
  }                                                 // RJR

  eOSState state = cOsdMenu::ProcessKey(Key);

  if (state == osUnknown) {
     switch (Key) {
       case kOk:
       case kRed:    return Play();
       case kGreen:  return Rewind();
       case kYellow: return Del();
       case kBlue:   return Summary();
       case kMenu:   return osEnd;
       default: break;
       }
     }
  return state;
}
--- schnapp -------------------------------------------------------

changes in menu.h:

extended class definition:

--- schnipp -------------------------------------------------------
class cMenuRecordings : public cOsdMenu {
private:
  cRecordings Recordings;
  eOSState Play(void);
  eOSState Rewind(void);
  eOSState Del(void);
  eOSState Summary(void);
  eOSState ExecuteScript(eKeys Key);             // RJR
public:
  cMenuRecordings(void);
  virtual eOSState ProcessKey(eKeys Key);
  };
--- schnapp -------------------------------------------------------

The scripts hich I use are named recordings_script_N and are placed in the
video0 directory. Here a sample script:

-------------- recordings_script_7 ----------------------------------
#!/bin/sh

#  ____________________________
#  VDR recording command script
#
#  Link the current recording to the vdr_converter directory.
#  First check whether the link already exists.
#
#  $Id: RecScript 0.1 2001/11/25 22:40:00 rjr Exp $

src_dir=$1
src_root=${src_dir:0:${#src_dir}-27}
dest_dir=/usr/tmp/convert/vdr_to_divx
command='ln -s '$src_root' '$dest_dir

logger -i -t recordings_script_7 Scheduling ${src_root} for DIVX conversion

${command}
--- schnapp -------------------------------------------------------

-----Original Message-----
From: vdr-bounce@linuxtv.org [mailto:vdr-bounce@linuxtv.org]On Behalf Of
Axel Gruber
Sent: Monday, March 04, 2002 11:31 AM
To: vdr@linuxtv.org
Subject: [vdr] Command wich transfer the Marked Filename for VDR ?


Hi all

First - iīm  not a Programmer so forgive me if itīs wrong what i write:

Iīm buring DVD-R with MY vdr with some scriptīs only by pressing some
Buttons on the Remote-Controll - thatīs ok

But i miss something:

It would be great it i could define a external Command-Line Programm
wich i can start out of the Recordings-Menu and to wich VDR transfer the
actual
marked Recording/Directory-Name as command-Line-option.

I think this would be a very usefull thing fo all who transcode, encode,
Burn,
save,.... ther Recordings.

Perhaps such a function is allready available and i donīt know it ? -
Please Mail what you think about it ?

CU

Axel Gruber




Home | Main Index | Thread Index