Mailing List Archive

Plex integration.
Hi.

Has anyone wrote a script that will automatically create a link in the
recordings folder (or any other folder for that matter) in such that
it will be recognised with Plex?

Thanks
Jean-Yves
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Plex integration. [ In reply to ]
On Mon, Mar 15, 2021 at 5:30 PM Jean-Yves Avenard <jyavenard@gmail.com>
wrote:

> Hi.
>
> Has anyone wrote a script that will automatically create a link in the
> recordings folder (or any other folder for that matter) in such that
> it will be recognised with Plex?
>

I have one that runs once a day. I never got around to trying to manage it
on the fly.

Thanks,
Richard
Re: Plex integration. [ In reply to ]
I guess I can post the details now...

# cat /usr/local/bin/plexlink
#!/bin/env bash

PLEXDIR=/var/lib/mythtv/plex

if [[ $# -eq 0 ]]; then
# Run for all recordings
/usr/local/bin/mythlink --link $PLEXDIR --format "%T - s%sse%ep"
/usr/bin/symlinks -c $PLEXDIR
else
# Run for a single recording
/usr/local/bin/mythlink --verbose --link $PLEXDIR --format "%T - s%sse%ep" \
--chanid $1 --starttime $2
/usr/bin/symlinks -cd $PLEXDIR
fi

# systemctl cat mythlink.service
# /etc/systemd/system/mythlink.service
[Unit]
Description=Update symbolic links of recordings for Plex
After=mythbackend.service
Requisite=mythbackend.service

[Service]
Type=simple
ExecStart=/usr/local/libexec/mythlink.sh

# systemctl cat mythlink.timer
# /etc/systemd/system/mythlink.timer
[Unit]
Description=Timer for the mythlink service

[Timer]
#OnCalendar=*-*-* 00:00:00
OnCalendar=daily
#OnUnitActiveSec=1d

[Install]
WantedBy=multi-user.target

Thanks,
Richard
Re: Plex integration. [ In reply to ]
I actually transcode my recordings as well and copy them, rather than just
link. Let me see whether it's ready for public consumption
--
Justin B. Alcorn
The views expressed are not necessarily my own, much less anyone else's
PGP Fingerprint CCEB F776 C3FD 1050 C8DB 532E B8B9 BED7 7764 406C


On Mon, Mar 15, 2021 at 6:28 PM Jean-Yves Avenard <jyavenard@gmail.com>
wrote:

> Hi.
>
> Has anyone wrote a script that will automatically create a link in the
> recordings folder (or any other folder for that matter) in such that
> it will be recognised with Plex?
>
> Thanks
> Jean-Yves
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://lists.mythtv.org/mailman/listinfo/mythtv-users
> http://wiki.mythtv.org/Mailing_List_etiquette
> MythTV Forums: https://forum.mythtv.org
>
Re: Plex integration. [ In reply to ]
> Has anyone wrote a script that will automatically create a link in the
> recordings folder (or any other folder for that matter) in such that
> it will be recognised with Plex?
>

There is, or at least used to be, a script called mythlink that was
designed for this type of thing. Not certain if it provides the format Plex
wants, but it was quite customisable so I would have thought it would work.

>
Re: Plex integration. [ In reply to ]
On 3/15/21 4:08 PM, Phill Edwards wrote:
>
> Has anyone wrote a script that will automatically create a link in the
> recordings folder (or any other folder for that matter) in such that
> it will be recognised with Plex?
>
>
> There is, or at least used to be, a script called mythlink that was
> designed for this type of thing. Not certain if it provides the format
> Plex wants, but it was quite customisable so I would have thought it
> would work.
>

Mythlink works well for this and can also be added as a Post Processing
job (user job) to automatically add links after a recording has
completed. The only recordings I don't get links for are sports games.
I also run a nightly mythlink cron job at 2am to catch any recording
that was deleted.

This works well for being able to watch recordings using a native tv app
since most tvs from the past several years have a Plex app available.
It's also a convenient way to be able to stream recordings while
traveling. Assuming, of course, that you have a Plex server for other
purposes.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Plex integration. [ In reply to ]
> Has anyone wrote a script that will automatically create a link in the
> recordings folder (or any other folder for that matter) in such that
> it will be recognised with Plex?

I have setup scripts for mythlink to be triggered by system events
Recording deleted
Recording expired
Recording finished

I did this to keep the backend load down, because it just adds a
single link rather than doing a full mythlink scan of all recordings.
For the recording finished I create two directory structures. That
way in Plex (although I've now changed to Jellyfin) I can use one
format for TV Shows and another for Movies. Also note I create
categories for the recordings using recording groups (the %U). This
is the way I separate Movies from TV Shows in both Mythtv and Plex.

Here is the main part of the scripts:

record_finish.sh
sleep 10
/usr/bin/ionice -c 3 /usr/bin/nice -n 19
/usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
--destination /tv/show_names/ --filename $1 --underscores --maxlength
120 --format "%U/%T/%Y-%m-%d %S S%ssE%ep"
sleep 2
/usr/bin/ionice -c 3 /usr/bin/nice -n 19
/usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
--destination /tv/show_names-movies/ --filename $1 --maxlength 120
--format "%U/%T/%T - %Y-%m-%d (%oY) %S"

For expired or finished I just search for missing links and delete them.
record_delete.sh
sleep 10
find /tv/show_names/ -xtype l -delete
find /tv/show_names-movies/ -xtype l -delete
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Plex integration. [ In reply to ]
> record_finish.sh
> sleep 10
> /usr/bin/ionice -c 3 /usr/bin/nice -n 19
> /usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
> --destination /tv/show_names/ --filename $1 --underscores --maxlength
> 120 --format "%U/%T/%Y-%m-%d %S S%ssE%ep"
> sleep 2
> /usr/bin/ionice -c 3 /usr/bin/nice -n 19
> /usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
> --destination /tv/show_names-movies/ --filename $1 --maxlength 120
> --format "%U/%T/%T - %Y-%m-%d (%oY) %S"
>

Forgot to mention in the system event for Recording finished - you
call the script by passing the filename.
e.g /directory_of_the_script/record_finish.sh %FILE%
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Plex integration. [ In reply to ]
On Tue, Mar 16, 2021 at 10:34 PM myth tv via mythtv-users <
mythtv-users@mythtv.org> wrote:

>
> Here is the main part of the scripts:
>
> record_finish.sh
> sleep 10
> /usr/bin/ionice -c 3 /usr/bin/nice -n 19
> /usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
> --destination /tv/show_names/ --filename $1 --underscores --maxlength
> 120 --format "%U/%T/%Y-%m-%d %S S%ssE%ep"
> sleep 2
> /usr/bin/ionice -c 3 /usr/bin/nice -n 19
> /usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
> --destination /tv/show_names-movies/ --filename $1 --maxlength 120
> --format "%U/%T/%T - %Y-%m-%d (%oY) %S"
>

How does it differentiate between a TV show or a movie? Or does it just
mangle one or the other so it doesn't work in Plex?

Thanks,
Richard
Re: Plex integration. [ In reply to ]
On Wed, Mar 17, 2021 at 10:55 PM Richard Shaw <hobbes1069@gmail.com> wrote:
>
> On Tue, Mar 16, 2021 at 10:34 PM myth tv via mythtv-users <mythtv-users@mythtv.org> wrote:
>>
>>
>> Here is the main part of the scripts:
>>
>> record_finish.sh
>> sleep 10
>> /usr/bin/ionice -c 3 /usr/bin/nice -n 19
>> /usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
>> --destination /tv/show_names/ --filename $1 --underscores --maxlength
>> 120 --format "%U/%T/%Y-%m-%d %S S%ssE%ep"
>> sleep 2
>> /usr/bin/ionice -c 3 /usr/bin/nice -n 19
>> /usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
>> --destination /tv/show_names-movies/ --filename $1 --maxlength 120
>> --format "%U/%T/%T - %Y-%m-%d (%oY) %S"
>
>
> How does it differentiate between a TV show or a movie? Or does it just mangle one or the other so it doesn't work in Plex?
>

I do two things to differentiate TV Shows and Movies.

1. Create different two directory structures and filenames because
Plex needs different structures for TV and Movies.
2. I use %U to separate out which mythtv programs are Movies and which
are TV Shows. This means using different recording groups for TV and
Movies when setting up a recording rule.

Then in Plex I point to the TV show recording groups in the first
mythlink directory structure when adding TV shows to the Plex library.
Then I point to the Movies recording groups in the second mythlink
directory structure for the Plex Movies library.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Plex integration. [ In reply to ]
On 18/03/2021 03:36, myth tv via mythtv-users wrote:
> On Wed, Mar 17, 2021 at 10:55 PM Richard Shaw <hobbes1069@gmail.com> wrote:
>>
>> On Tue, Mar 16, 2021 at 10:34 PM myth tv via mythtv-users <mythtv-users@mythtv.org> wrote:
>>>
>>>
>>> Here is the main part of the scripts:
>>>
>>> record_finish.sh
>>> sleep 10
>>> /usr/bin/ionice -c 3 /usr/bin/nice -n 19
>>> /usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
>>> --destination /tv/show_names/ --filename $1 --underscores --maxlength
>>> 120 --format "%U/%T/%Y-%m-%d %S S%ssE%ep"
>>> sleep 2
>>> /usr/bin/ionice -c 3 /usr/bin/nice -n 19
>>> /usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
>>> --destination /tv/show_names-movies/ --filename $1 --maxlength 120
>>> --format "%U/%T/%T - %Y-%m-%d (%oY) %S"
>>
>>
>> How does it differentiate between a TV show or a movie? Or does it just mangle one or the other so it doesn't work in Plex?
>>
>
> I do two things to differentiate TV Shows and Movies.
>
> 1. Create different two directory structures and filenames because
> Plex needs different structures for TV and Movies.
> 2. I use %U to separate out which mythtv programs are Movies and which
> are TV Shows. This means using different recording groups for TV and
> Movies when setting up a recording rule.
>
> Then in Plex I point to the TV show recording groups in the first
> mythlink directory structure when adding TV shows to the Plex library.
> Then I point to the Movies recording groups in the second mythlink
> directory structure for the Plex Movies library.
>
Yeah, but... your script above places links in /both/ Movies and TV directories at the end of every
program.

--

Mike Perkins

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Plex integration. [ In reply to ]
On Thu, Mar 18, 2021 at 9:20 PM Mike Perkins
<mikep@randomtraveller.org.uk> wrote:
>
> On 18/03/2021 03:36, myth tv via mythtv-users wrote:
> > On Wed, Mar 17, 2021 at 10:55 PM Richard Shaw <hobbes1069@gmail.com> wrote:
> >>
> >> On Tue, Mar 16, 2021 at 10:34 PM myth tv via mythtv-users <mythtv-users@mythtv.org> wrote:
> >>>
> >>>
> >>> Here is the main part of the scripts:
> >>>
> >>> record_finish.sh
> >>> sleep 10
> >>> /usr/bin/ionice -c 3 /usr/bin/nice -n 19
> >>> /usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
> >>> --destination /tv/show_names/ --filename $1 --underscores --maxlength
> >>> 120 --format "%U/%T/%Y-%m-%d %S S%ssE%ep"
> >>> sleep 2
> >>> /usr/bin/ionice -c 3 /usr/bin/nice -n 19
> >>> /usr/share/doc/mythtv-backend/contrib/user_jobs/mythlink.pl
> >>> --destination /tv/show_names-movies/ --filename $1 --maxlength 120
> >>> --format "%U/%T/%T - %Y-%m-%d (%oY) %S"
> >>
> >>
> >> How does it differentiate between a TV show or a movie? Or does it just mangle one or the other so it doesn't work in Plex?
> >>
> >
> > I do two things to differentiate TV Shows and Movies.
> >
> > 1. Create different two directory structures and filenames because
> > Plex needs different structures for TV and Movies.
> > 2. I use %U to separate out which mythtv programs are Movies and which
> > are TV Shows. This means using different recording groups for TV and
> > Movies when setting up a recording rule.
> >
> > Then in Plex I point to the TV show recording groups in the first
> > mythlink directory structure when adding TV shows to the Plex library.
> > Then I point to the Movies recording groups in the second mythlink
> > directory structure for the Plex Movies library.
> >
> Yeah, but... your script above places links in /both/ Movies and TV directories at the end of every
> program.
>

That's correct, each program is creates a mythlink twice because I
don't check at the time of creating the mythlink whether it is a movie
or TV show. I guess it could be smarter and test the %U value and only
create either the TV or Movie link.
However, in Plex libraries I don't point to the top of the Movie or TV
directory structure but to the relevant %U sub-directories.
These are my Recording Groups (%U)
Children's TV
Children's Movies
Documentaries
Movies Classic
Movies
Infotainment
General
etc. etc.

So in Plex when creating my Movie Library, I add all the directories
for "movie type" recording groups but only in the second mythlink
movie directory structure. That way Plex knows they are movies and
uses the correct information (directory structure and filename) for
the database grabbers.
While for the TV Show Library, I add recording group directories from
the first mythlink directory structure. This directory structure is
in the format that Plex likes to gather TV show information.

BTW: The mythlink options may not be optimized for Plex or the quality
of the guide data of others. I've moved from Plex to Jellyfin and
find my mythlink options quite good for the guide data I have.

Perhaps it is a good idea to test the %U value and only create the
mythlink once, then Plex would just need the top level directory in
each TV and Movie libraries. However, the for the way above I do get
to choose what is included or excluded from Plex based on mythtv
recording category.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Plex integration. [ In reply to ]
This script doesn't create links - it transcodes the recordings to the
settings I like for plex and copies to a new file.

https://github.com/jbalcorn/mythtv-plex


--
Justin B. Alcorn
The views expressed are not necessarily my own, much less anyone else's
PGP Fingerprint CCEB F776 C3FD 1050 C8DB 532E B8B9 BED7 7764 406C


On Mon, Mar 15, 2021 at 6:28 PM Jean-Yves Avenard <jyavenard@gmail.com>
wrote:

> Hi.
>
> Has anyone wrote a script that will automatically create a link in the
> recordings folder (or any other folder for that matter) in such that
> it will be recognised with Plex?
>
> Thanks
> Jean-Yves
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://lists.mythtv.org/mailman/listinfo/mythtv-users
> http://wiki.mythtv.org/Mailing_List_etiquette
> MythTV Forums: https://forum.mythtv.org
>
Re: Plex integration. [ In reply to ]
On Fri, 19 Mar 2021 at 23:27, Justin Alcorn <justin@jalcorn.net> wrote:
>
> This script doesn't create links - it transcodes the recordings to the settings I like for plex and copies to a new file.
>
> https://github.com/jbalcorn/mythtv-plex
>

My backend is powerful enough to transcode on the fly, so I let plex
automatically do that for me, which will vary according to the
detected bandwidth at the time you're watching something.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: Plex integration. [ In reply to ]
On 25/03/2021 05:15, Jean-Yves Avenard wrote:
> On Fri, 19 Mar 2021 at 23:27, Justin Alcorn <justin@jalcorn.net> wrote:
>>
>> This script doesn't create links - it transcodes the recordings to the settings I like for plex and copies to a new file.
>>
>> https://github.com/jbalcorn/mythtv-plex
>>
>
> My backend is powerful enough to transcode on the fly, so I let plex
> automatically do that for me, which will vary according to the
> detected bandwidth at the time you're watching something.

I haven't used plex, or that script, but I noticed that the script
should be able to 'honor the cutlist', which is a good thing for
recordings that might be watched more than once...

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org