Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add report script feature to GUI #181

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ RUN \
ENV \
MAKEMKV_KEY=BETA \
MAKEMKV_GUI=1 \
MAKEMKV_REPORT_SCRIPT= \
AUTO_DISC_RIPPER=0 \
AUTO_DISC_RIPPER_MAKEMKV_PROFILE= \
AUTO_DISC_RIPPER_EJECT=0 \
Expand Down
37 changes: 37 additions & 0 deletions appdefs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,43 @@ app:
to `1`), it is recommended, to minimize impact on ripping speed, to
increase the interval at which the presence of new discs is checked
(`AUTO_DISC_RIPPER_INTERVAL`).
- title: Capture Events of MakeMKV GUI
level: 2
content: |-
By setting the `MAKEMKV_REPORT_SCRIPT` environment variable to point to an
executable, you're able to capture events that are sent to the GUI. This is
useful if you want to automatically post-process media.

**NOTE**: This isn't implemented yet for the automatic disc ripper!

If set, the script is called for every event that is logged in the log window
of the GUI. The logged data is passed through environment variables to your
script:

- `MAKEMKV_CODE` The code of the log event, see below
- `MAKEMKV_TEXT` The (localized) text of the log event
- `MAKEMKV_PATH` The current output path

**NOTE**: If you don't want to bake your own docker image, you can put your
script into the config/ directory.
- title: Codes
level: 3
content: |-
- `5011` Analysis of an opened disc has finished, waiting for the user to proceed
- `5014` Ripping start of a title
- `5005` Ripping finish of a title
- `5036` Ripping of all requested titles has finished successfully
- Many more
- title: Sample Script
level: 3
content: |-
This scripts simply logs all events into report.log in the config directory.
Save it as config/report.sh and set `MAKEMKV_REPORT_SCRIPT=/config/report.sh`.

```sh
#!/bin/sh
echo "$(date) ${MAKEMKV_CODE} ${MAKEMKV_PATH} ${MAKEMKV_TEXT}" >> /config/report.log
```
- title: Troubleshooting
level: 2
- title: Expired Beta Key
Expand Down
1 change: 1 addition & 0 deletions src/makemkv-oss/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ MAKEMKV_COMPILED_BINS="\
log "Patching MakeMKV..."
patch -d /tmp/makemkv -p1 < "$SCRIPT_DIR/fix-include.patch"
patch -d /tmp/makemkv -p1 < "$SCRIPT_DIR/launch-url.patch"
patch -d /tmp/makemkv -p1 < "$SCRIPT_DIR/report-script.patch"

log "Configuring MakeMKV..."
(
Expand Down
37 changes: 37 additions & 0 deletions src/makemkv-oss/report-script.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/makemkvgui/src/mainwnd.cpp b/makemkvgui/src/mainwnd.cpp
index b69b6e5..8716922 100644
--- a/makemkvgui/src/mainwnd.cpp
+++ b/makemkvgui/src/mainwnd.cpp
@@ -25,6 +25,23 @@
#include "dvdbox.h"
#include "drivebox.h"
#include "image_defs.h"
+#include <QProcess>
+
+static void invokeReportScript(unsigned long code, const QString &text, const QString &path) {
+ static QString reportScript = qEnvironmentVariable("MAKEMKV_REPORT_SCRIPT");
+ if (reportScript.isEmpty()) return;
+
+ QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
+ env.insert("MAKEMKV_CODE", QString::number(code));
+ env.insert("MAKEMKV_TEXT", text);
+ env.insert("MAKEMKV_PATH", path);
+
+ QProcess process;
+ process.setProgram(reportScript);
+ process.setArguments({});
+ process.setProcessEnvironment(env);
+ process.startDetached();
+}

MainWnd* MainWnd::m_myself_static=NULL;

@@ -1070,6 +1087,8 @@ int MainWnd::ReportUiMessage(
return 0;
}

+ invokeReportScript(Code, QStringFromUtf8(Text), saveFolderBox->text());
+
// look if this is a dialog-box message and dispatch it here
if (( (Flags&AP_UIMSG_BOX_MASK) == AP_UIMSG_BOXOK ) ||
( (Flags&AP_UIMSG_BOX_MASK) == AP_UIMSG_BOXERROR ) ||