bljohnsondev / comcutter

A container with a REST API that wraps comskip and comchap for handling commercial skipping.
5 stars 0 forks source link

Help to understand #1

Closed joe2707 closed 9 months ago

joe2707 commented 10 months ago

Hi Can you help me to understand this better ? I've built container with docker compose as per the readme but how do I generate an API to use with the script ?

And do I put the script into an sh file chmod +X the file and put the path in the post processing script box within emby ?

Any advice is much appreciated.

Thanks

bljohnsondev commented 10 months ago

Hi there!

The docker container that gets created has the API endpoint you need to call from your Emby server.

You then need to create a shell script like the one I provided in the example and that script needs to be available in your Emby container. I'm using Jellyfin and what I did was create a volume mount that mounts a folder that has the script in it to something like /scripts. So let's assume you called your script call-comcutter.sh.

I haven't used Emby but with Jellyfin you go to the Admin Dashboard and under "DVR" there is a setting called Post-processing application. In there you would set that to /scripts/call-comcutter.sh.

When a recording gets done it will run that script which makes an API call to your comcutter container that starts the process of stripping out the commercials.

One thing to remember is that the comcutter API really wants the relative path (relative to your media folder) to the file that was recorded. I really should update the examples to make this more clear.

So, let's say you have a volume mount in your Emby container to /data/media where your media library resides and you just got done recording a Family Guy episode. It records to /data/media/dvr/Family Guy/Season 22/Family Guy S22E05 Old World Harm.ts. It will send this full path to comcutter given the example I posted.

You only want to send the relative path without the /data/media part. In this example you only want to send dvr/Family Guy/Season 22/Family Guy S22E05 Old World Harm.ts.

How I do this is with the following script as an example.

#!/bin/bash

filepath="$@"

# example file - '/data/media/dvr/Family Guy/Season 22/Family Guy S22E05 Old World Harm.ts'
stripped=`echo "$filepath" | cut -c 12-`

curl -X POST \
  http://localhost:9090/comskip \
  -H 'Content-Type: application/json' \
  -d "{\"api\": \"ABC123\", \"file\": \"${stripped}\"}"

This will strip out /data/media (the cut -c 12- part removes the first 12 characters) and only send the rest of the path to comcutter. Then just make sure you create a volume mount in comcutter that maps /data/media to /library (or whatever you set if you changed the library_dir config variable).

Does that help or did I confuse you even more? Let me know if you have any other questions and I'll do my best to help.

joe2707 commented 10 months ago

Hi,

Thanks very much for the explanation.

Im sure I'm being dumb, but where do I get the API key from to enter into the script ? As in your example "ABC123"

Thanks !

On Sun, 3 Dec 2023, 05:40 Brent Johnson, @.***> wrote:

Hi there!

The docker container that gets created has the API endpoint you need to call from your Emby server.

You then need to create a shell script like the one I provided in the example and that script needs to be available in your Emby container. I'm using Jellyfin and what I did was create a volume mount that mounts a folder that has the script in it to something like /scripts. So let's assume you called your script call-comcutter.sh.

I haven't used Emby but with Jellyfin you go to the Admin Dashboard and under "DVR" there is a setting called Post-processing application. In there you would set that to /scripts/call-comcutter.sh.

When a recording gets done it will run that script which makes an API call to your comcutter container that starts the process of stripping out the commercials.

One thing to remember is that the comcutter API really wants the relative path (relative to your media folder) to the file that was recorded. I really should update the examples to make this more clear.

So, let's say you have a volume mount in your Emby container to /data/media where your media library resides and you just got done recording a Family Guy episode. It records to /data/media/dvr/Family Guy/Season 22/Family Guy S22E05 Old World Harm.ts. It will send this full path to comcutter given the example I posted.

You only want to send the relative path without the /data/media part. In this example you only want to send dvr/Family Guy/Season 22/Family Guy S22E05 Old World Harm.ts.

How I do this is with the following script as an example.

!/bin/bash

filepath="$@"

example file - '/data/media/dvr/Family Guy/Season 22/Family Guy S22E05 Old World Harm.ts'

stripped=echo "$filepath" | cut -c 12-

curl -X POST \ http://localhost:9090/comskip \ -H 'Content-Type: application/json' \ -d "{\"api\": \"ABC123\", \"file\": \"${stripped}\"}"

This will strip out /data/media (the cut -c 12- part removes the first 12 characters) and only send the rest of the path to comcutter. Then just make sure you create a volume mount in comcutter that maps /data/media to /library (or whatever you set if you changed the library_dir config variable).

Does that help or did I confuse you even more? Let me know if you have any other questions and I'll do my best to help.

— Reply to this email directly, view it on GitHub https://github.com/bljohnsondev/comcutter/issues/1#issuecomment-1837377852, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASVF2HNVFQPKEOOT4N4ZNQDYHQGFPAVCNFSM6AAAAABAD5MAEGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZXGM3TOOBVGI . You are receiving this because you authored the thread.Message ID: @.***>

bljohnsondev commented 10 months ago

You just need to generate a key. You can choose something yourself or in Linux you can run a command like echo $RANDOM | md5sum | head -c 20; echo; that will create a randomly generated 20 character string.

Use that string in the curl command in the shell script to pass that to the API and make sure you set the same key in the config.yml file (the apikey setting). It checks for a matching key before processing the request. The config.yml file should get auto generated for you with sample values the first time the container runs.

bljohnsondev commented 9 months ago

I've updated the README to include more information related to absolute and relative paths used in the script. I'm going to close this issue. If you have any more questions let me know.