[mythtv-users] symlinking recordings for Plex using mythlink

Justin Alcorn justin at jalcorn.net
Wed Aug 8 15:38:02 UTC 2018


Here's some of the relevant code.   It's not everything, but it should get
you started.

This was written just for TV shows, then I added the movie bit.

(plextitle is a table I created that allows me to translate titles that
have invalid characters for filenames)


plextitle=`echo "select plextitle from plexnames where title=\"$title\";" |
$mysqlconnect`
if [ -z "$plextitle" ];then
        plextitle=`echo $title |  sed -e "s/ /${separator}/g" | sed -e
"s/[,\/\"\'\.()]//g"`
fi
season=`echo "select season from recorded where basename=\"$BASENAME\";" |
$mysqlconnect`
episode=`echo "select episode from recorded where basename=\"$BASENAME\";"
| $mysqlconnect`

info=`echo "select title, subtitle from recorded where
basename=\"$BASENAME\";" | $mysqlconnect`
echo "Basename = $BASENAME"
echo "Season $season Episode $episode"
echo $info
echo '**************************************************************'

if [ $episode -gt 0 ]
then
        s=`printf %02d $season`
        e=`printf %02d $episode`
        se="S${s}E${e}."
else
        se=""
fi

if [ -n "$subtitle" ];then
        t=`echo $subtitle |  sed -e "s/ /${separator}/g" | sed -e
"s/[,;\/\"\'\.()]//g"`
        t="${t}."
else
        t=""
fi

...
echo "Checking for Directory ${tvlib}/${plextitle}"
if [ -d "${tvlib}/${plextitle}" ]
then
        FINALFILE="${tvlib}/${plextitle}/${plextitle}.${se}${t}${finalext}"
        if [ -z "${se}" ];then
                echo $FINALFILE | mail -s "No Season/Episode for
${FINALFILE}" jbalcorn at gmail.com
        fi
elif [[ $programid =~ ^MV ]];then
        airdate=`echo "SELECT airdate FROM program WHERE programid =
'${programid}';" | $mysqlconnect`
        if [ -z "$airdate" ];then
                airdate=`echo "SELECT originalairdate FROM recorded WHERE
basename=\"$BASENAME\";" | $mysqlconnect`
                mvyear=`echo $airdate | cut -d'-' -f1`
        else
                mvyear=`echo $airdate | cut -d' ' -f1`
        fi

FINALFILE="/mnt/disk/share/movies/${plextitle}.${mvyear}.${finalext}"
else
        PREFIXDT=`date -d "${starttime} UTC" "+%Y-%m-%d"`
        PREFIXTITLE=`echo $plextitle | sed -e "s/${separator}/ /g"`
        FINALFILE="${reclib}/${PREFIXTITLE} ${PREFIXDT}.${t}${finalext}"
fi
echo "Final File will be ${FINALFILE}"


I use the FINALFILE as output for transcode, you could just  use it for the
symbolic link.
-- 
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 Wed, Aug 8, 2018 at 11:28 AM Justin Alcorn <justin at jalcorn.net> wrote:

> You'd have to write your own but it's not difficult.  I transcode and cut
> the movies and TV shows and I look up the year of the movie using the
> 'airdate' field in the 'program' table to name the movies name.year.mp4.  I
> know it's a movie because the programid starts with 'MV'
>
> It could easily do the same to just create the symlinks
> --
> 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, Aug 6, 2018 at 1:04 AM Mark Perkins <perkins1724 at hotmail.com>
> wrote:
>
>> Has anyone looked into how mythlink.pl can be used to create 'readable'
>> filename links that can be parsed by Plex - particularly / specifically
>> also
>> placing tv shows in a different folder to movies?
>>
>> mythlink.pl seems to have quite an extensive amount of options but I
>> can't
>> immediately determine a way to separate movies into a different directory
>> /
>> hierarchy to tv shows.
>>
>>
>>
>> _______________________________________________
>> mythtv-users mailing list
>> mythtv-users at mythtv.org
>> http://lists.mythtv.org/mailman/listinfo/mythtv-users
>> http://wiki.mythtv.org/Mailing_List_etiquette
>> MythTV Forums: https://forum.mythtv.org
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mythtv.org/pipermail/mythtv-users/attachments/20180808/6ece20e3/attachment.html>


More information about the mythtv-users mailing list