[mythtv-users] MythWeb filename to actual filename

David Fishburn dfishburn.mythtv at gmail.com
Wed Apr 8 03:07:31 UTC 2009


On Tue, Apr 7, 2009 at 12:33 AM,  <mythtv-users-request at mythtv.org> wrote:
>
> From: Nick Rout
> Subject: Re: [mythtv-users] MythWeb filename to actual filename

> On Tue, Apr 7, 2009 at 1:55 PM, David Fishburn
> <dfishburn.mythtv at gmail.com> wrote:
>>>   2. Re: MythWeb filename to actual filename (Steve Daniels)
>>
>>>> How do you map this URL:
>>>>    mythweb/tv/detail/1010/1238544000
>>>>
>>>> To the actual filename on the filesystem?
>>>>
>>>> I would have thought there would be a:
>>>>    recordings/1010_1238544000.mpg
>>
>>> Quick question, why do you want to do this?
>>>
>>> Steve Daniels
>>
>> I am trying to manually run an ffmpeg command line to transcode the
>> show for a new device.
>>
>> Also, often I just want to manually run an ffmpeg command line for a given show.
>>
>> Trying to find the file out of my 1000s of recorded shows is a bit
>> like a needle in a haystack.
>
> Not really. The path offered has the start of the filename (the first
> four characters) as the path element like:
>
> mythweb/tv/detail/1010/1238544000
>
> the filename starts with 1010_
>
> The rest of it is made up of the date & time the recording started,
> which is shown in mythweb. The format is YYYYMMDDHHMM00.mpg. Its
> pretty easy to type
>
> 1010_20090407154000.mpg, particularly with the info sitting in mythweb
> in front of you and tab completion helping.
>
> Also we are told earlier in the thread that the mysterious numbers
> 1238544000 are the time in Unix time. using the date function it would
> be easy to convert to the right format.
>
> $ date -d @1238544000 +%Y%m%d%H%M%S
>
> 20090104130000
>
> (it shows 1300 hours, like 1 pm because its given in my localtime, UTC+1300
>
> see the date man page. I read that the @epochtime only works with
> recent versions of date, otherwise a short perl one line seems to be
> the required trick.
>
> The format pattern is a pain to type but easy to script.

Thanks for the hints Nick.

My rudimentary shell scripting produced this script which does what I need.
If someone can offer any improvements on it terrific.
I actually have to check 2 locations, since I stored recordings in 2
different locations.  I just removed the second check from the script.
I don't know if it is possible to ask Myth for the recording directory
locations (to make the script more generic) but it is a simple change
as is if things move.

***********************
#!/bin/sh
#
# Example call
# /home/mythtv/bin/mythweb_file.sh
http://fishburns.homedns.org/mythweb/tv/detail/
>>1010/1238025600
#
MYTHWEB_URL=$1
RECORDING_CHAN=`echo $MYTHWEB_URL | sed -e
's/.*detail\/\([0-9]\+\)\/[0-9]\+/\1/'`
RECORDING_TIME=`echo $MYTHWEB_URL | sed -e 's/.*\/\([0-9]\+\)/\1/'`
RECORDING_DATE=`date -d @$RECORDING_TIME +%Y%m%d%H%M%S`

echo "URL :$MYTHWEB_URL"
echo "CHAN:$RECORDING_CHAN"
echo "TIME:$RECORDING_TIME"
echo "DATE:$RECORDING_DATE"

MYTH_FILE="/media/mythtv/recordings/${RECORDING_CHAN}_${RECORDING_DATE}.mpg"
if [ -f $MYTH_FILE  ]; then
       echo "Found:$MYTH_FILE"
       exit 0
fi

echo "Cannot find MythTV file for:$MYTHWEB_URL"

exit 1
***********************

Dave


More information about the mythtv-users mailing list