NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Support v
« Previous 1 … 31 32 33 34 35 … 43 Next »
Using PostPocessing to move recordings

 
  • 0 Vote(s) - 0 Average
Using PostPocessing to move recordings
ballfam
Offline

Member

Australia
Posts: 132
Threads: 11
Joined: Jul 2020
#11
2020-07-24, 03:35 AM
OK, this was much easier than I thought, I was just getting in my own head with shell scripting, it all came back to me quickly. I knocked this up in about an hour this evening.

Of course, as always, the real version is more complicated than I made out. Only some channels need recoding, so I created an alternate recording location in ToRecode to place files that need to be recoded. In the script, I only rename files that are in ToRecode.

Martrin, what was the point in the dotnet command in your script, do I need to include that to make NextPVR do something?

Code:
#!/bin/bash
infile=$1
# only move files in the recode location
if [[ "$1" == *"ToRecode"* ]]; then
  # use string matching to replace ToRecode with Recode in the path
  plex_file="${infile/ToRecode/Recode}"
  # create target dir in case it does not yet exist
  target_dir=$(dirname "$plex_file")
  mkdir -p $target_dir
  # move the file to the Plex location
  mv "$1"  "$plex_file"
fi
ballfam
Offline

Member

Australia
Posts: 132
Threads: 11
Joined: Jul 2020
#12
2020-07-24, 03:44 AM
ahh, it just occurred to me, the dotnet command probably tells NextPVR where the file went to so it doesn't think the recording is gone. Is that right?
Graham
Offline

Posting Freak

UK
Posts: 4,058
Threads: 102
Joined: Dec 2005
#13
2020-07-24, 10:14 AM
(2020-07-24, 03:44 AM)ballfam Wrote: ahh, it just occurred to me, the dotnet command probably tells NextPVR where the file went to so it doesn't think the recording is gone. Is that right?

Yep ... NextPVR stores info about recordings in npvr.db3 ... https://github.com/sub3/NextPVR/wiki/components

nscripthelper.dll updates the database ... https://github.com/sub3/NextPVR/wiki/nscripthelper
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,835
Threads: 954
Joined: May 2006
#14
2020-07-24, 12:51 PM
For linux you will need to create this file to get NScriptHelper to work https://forums.nextpvr.com/showthread.ph...#pid544020

Martin
ballfam
Offline

Member

Australia
Posts: 132
Threads: 11
Joined: Jul 2020
#15
2020-07-24, 02:47 PM
OK, thanks, that might explain why it didn't quite work for my recordings last night. Everything was all good and Plex was happy, but there were 2 minor issues:


  1. The XML file doesn't get moved. Since I never play the media in NextPVR and Plex seems to have no need for this file, it's not a big deal, but it may also explain point 2. I'm assuming it contains some meta-data about the recording. Is it useful to NextPVR? Should I move it also?
  2. NextPVR loses track of the file as soon as it is moved, thich means that dotnet command is not working (I added it before recording yesterday) like so:


Code:
/opt/dotnet/dotnet /opt/nextpvr/system/NScriptHelper.dll  -rename "$1" "$plex_file"





           In guess the extra step you describe would explain it, but odes it also need the XML?
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,835
Threads: 954
Joined: May 2006
#16
2020-07-24, 02:55 PM (This post was last modified: 2020-07-24, 02:56 PM by mvallevand.)
My example on moved .ts you'd need to be more complicated if you create the xml files. Just turn off xml creation or delete it in your script. It is only a backup of metadata The only value I could see for plex is if you could code a .xml to .nfo convert utility, it wouldn't be hard.

You definitely will need that .json file for NScriptHelper

Martin
ballfam
Offline

Member

Australia
Posts: 132
Threads: 11
Joined: Jul 2020
#17
2020-07-24, 10:28 PM (This post was last modified: 2020-07-25, 03:47 AM by ballfam.)
Not sure if this  is useful to anyone, but I'll post it just in case.

An additional problem I have is that the EPG being used (Australian broadcasters) does not distinguish between new shows and repeats, and some channels broadcast more than one repeat of diferent episodes of the same show on the same day. NextPVR is fine because it uses the timestamp to distinguish the file, but Plex cannot handle more than one episode of the same show on the same day if it has no original broadcast date (which does not exist in my EPG), and it ends up trying to recde the 2 episodes to the same target, since it only uses date stamp. It is a failing in Plex which they know about, but I have managed to work around it in my PostPocessing script; I just look to see if there is already another file in the target location with the same date (checked up to 5 times), and if there is, I change the date on rename. Not a perfect solution, but it avoids clashes in most cases. Anyway, here's the new version of the code:

Code:
#!/bin/bash
infile=$1
count=1
file_check=1
# only move files in the recode location
if [[ "$1" == *"ToRecode"* ]]; then
  # use string matching to replace ToRecode with Recode in the path
  plex_file="${infile/ToRecode/Recode}"
  # create target dir in case it does not yet exist
  target_dir=$(dirname "$plex_file")
  mkdir -p "$target_dir"
  # check if dated file already exists
  # check up to 5 times
  while [[ $count < 5 && $file_check == 1 ]]; do
    file_check=0
    copy_date=$(echo $(basename "$plex_file") | awk -F '[_.]' '{print $2}')
    while read -r file; do
      file_date=$(echo $(basename "$file") | awk -F '[_.]' '{print $2}')
      if [[ "$file_date" == "$copy_date" ]]; then
        new_date=$(echo $copy_date | awk -F '[-.]' '{print $3}')
        new_date=$(($new_date + 1))
        next_date=$(echo $copy_date | awk -v nd=$new_date -F '[-.]' '{print $1"-"$2"-"nd}')
        new_file=$(echo $(basename "$plex_file") | awk -v nd=$next_date -F '[_.]' '{print $1"_"nd"_"$3}')
        new_loc=$(dirname "$plex_file")"/"$new_file".ts"
        plex_file=$new_loc
        file_check=1
      fi
    done <<< "`find "$target_dir" -name *.ts`"
    count=$((count + 1))
  done
  # move the file to the Plex location
  mv "$1"  "$plex_file"
  # tell NextPVR where it went
  /opt/dotnet/dotnet /opt/nextpvr/system/NScriptHelper.dll  -rename "$1" "$plex_file"
fi


I'm also going to add a line to remove the XML file for now since I don't need it, but it may be handy to have at some point.
ballfam
Offline

Member

Australia
Posts: 132
Threads: 11
Joined: Jul 2020
#18
2020-07-26, 03:42 PM
One caveat that is worth mentioning. After adding the JSON file, the NextPVR rename was still not working. Not a big deal because I'm not using NextPVR to watch the recording; but then yesterday, I needed to restart the server after installing more memory, and I noticed that it started working.

The conclusion is that after adding the JSON file, NextPVR doesn't seem to pick it up until it is restarted. If anyone comes across this, remember to restart NextPVR after creating the JSON script.
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 52,835
Threads: 954
Joined: May 2006
#19
2020-07-26, 03:48 PM
That is very unlikely as it is loaded dynamically by the dotnet command and this script has nothing to do with NextPVR. It will be something else.

Martin
ballfam
Offline

Member

Australia
Posts: 132
Threads: 11
Joined: Jul 2020
#20
2020-07-27, 03:10 AM
Yes, that makes complete sense. Not sure what caused it but, but it just magically started working after a reboot, nothing else changed. Oh well, happy it worked, and I finally have a "set it and forget it" recording system, where stuff just magically shows up on my Plex clients after it has been recorded. NextPVR seems to be rock solid. Good job Sub.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (2): « Previous 1 2


Possibly Related Threads…
Thread Author Replies Views Last Post
  Recurring recording creates multiple recordings of same event txinga 2 325 2025-03-29, 12:33 AM
Last Post: txinga
  Recurring Recordings Not Working After Merging Channels BrettB 2 246 2025-02-06, 04:00 AM
Last Post: mvallevand
  Moving recordings to a fileserver SickBoy 1 241 2025-02-01, 02:39 PM
Last Post: mvallevand
  recordings prematurely 'stop' moonmeat 3 430 2025-01-24, 02:08 PM
Last Post: mvallevand
  What would happen if I change file locations and names of the recordings? Luisy44 4 555 2024-10-15, 01:15 AM
Last Post: Luisy44
  Why are my recordings not recording completely? Luisy44 6 846 2024-10-12, 07:01 PM
Last Post: Luisy44
  Recordings import issue Jaggy 4 550 2024-08-25, 12:03 AM
Last Post: Jaggy
  Recurring recordings not getting scheduled ginge6000 1 378 2024-07-12, 10:58 AM
Last Post: mvallevand
  Audio Format of Recordings (AAC LC SBR) jayg30 5 1,751 2023-12-08, 04:10 AM
Last Post: jayg30
  IPTV Recordings not finishing - Too many retries...giving up Ade_AV 3 839 2023-12-05, 07:08 AM
Last Post: Ade_AV

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode