MythTV XBMC renamer.

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
outleradam Offline
Member+
Posts: 1,722
Joined: Sep 2009
Reputation: 20
Location: Louisiana
Post: #11
Sorry, I will try to make my future posts nicer. I will use smileys.

I saw that your post used perl and I did not have perl.Eek So then I typed apt-get install perl Laugh After that I viewed the code Frown and I figured out that I needed to change settings. Confused so I did Shocked

Code:
$recordings_dir = '/var/lib/mythtv/recordings';
$output_dir = '/var/lib/mythtv/recordings/organized';

$mysql_host = 'localhost';
$mysql_db = 'mythconverg';
$mysql_user = 'mythtv';
$mysql_password =
Nod

Use mythicalLibrarian to make a library out of your MythTV files. Leave the recording to MythTV and use XBMC as your library.
Installation and Instructions:http://wiki.xbmc.org/index.php?title=MythicalLibrarian
Technical Support:http://forum.xbmc.org/showthread.php?tid=65644
[Image: newsig-1.png]
[url=http://forum.xda-developers.com/showthread.php?tid=1081892][/url]
find quote
outleradam Offline
Member+
Posts: 1,722
Joined: Sep 2009
Reputation: 20
Location: Louisiana
Post: #12
Then I set up a job as hdpvrcutter %TITLE% %SUBTITLE% Big Grin Then I went to the webadmin and started the job on a file I had recorded and it changed the name, but not to what I wanted No So then I tried again and it did some file operation Stare So then I went through the code and added debug lines for logging purposes to find out what was going wrong even though I don't know perl Rofl Then I changed ownership and permissions to the myth home dir to 777 make hdpvrcutter work Oo then I tried changing permissions to 777 for the myth recording dir. Shocked

Use mythicalLibrarian to make a library out of your MythTV files. Leave the recording to MythTV and use XBMC as your library.
Installation and Instructions:http://wiki.xbmc.org/index.php?title=MythicalLibrarian
Technical Support:http://forum.xbmc.org/showthread.php?tid=65644
[Image: newsig-1.png]
[url=http://forum.xda-developers.com/showthread.php?tid=1081892][/url]
find quote
outleradam Offline
Member+
Posts: 1,722
Joined: Sep 2009
Reputation: 20
Location: Louisiana
Post: #13
Then I moved the hdpvr cutter from mythtv to the file dir and I reset the job as ../hdpvrcutter title subtitle again.Angry Then I tried running the job manually Angry Then I tried running the job manually as rootAngry Then after 4 hours I gave up Angry

sorry, i had to split the post up because there were too many smileys.

Use mythicalLibrarian to make a library out of your MythTV files. Leave the recording to MythTV and use XBMC as your library.
Installation and Instructions:http://wiki.xbmc.org/index.php?title=MythicalLibrarian
Technical Support:http://forum.xbmc.org/showthread.php?tid=65644
[Image: newsig-1.png]
[url=http://forum.xda-developers.com/showthread.php?tid=1081892][/url]
find quote
theophile Offline
Fan
Posts: 569
Joined: Jan 2009
Reputation: 30
Post: #14
outleradam Wrote:The above will output a name, but only if it is absolutely correct.
The reason I used perl for my script instead of bash is primarily because someone on the Mythbuntu forum wrote a metadata script for TVDB that uses a Levenshtein distance analysis for matching show and episode name string between the input and the TVDB query results. The result is that it's 100% accurate even with minor to moderate variations in name.

I also opted for the GetEpisodeByAirdate.php route because I didn't want it downloading and parsing xml files. While I'm sure there are advantages to that approach, you've already stumbled onto one of the disadvantages: figuring out how to manage a local "database" of TV show information. The downside to my approach is that it can't tell the difference between two different episodes that originally aired on the same day. I decided that this was a rare enough eventuality that I didn't mind fixing those few occurrences by hand.

Now, to the real point, my script is designed to transcode MythTV recordings, but it would be trivial to have it simply rename them or create symlinks. In that case, the only dependency (besides Perl, obviously) would be the LWP::UserAgent module. Avidemux, the mythcommflag patch, and mkvtoolnix are only used for the transcoding process.

If you want to do that, I'd be happy to help provided you quit being so hostile. If you want to stick to your approach (which you have a very good start on), by all means.

One little suggestion would be to have it check for the existence of the showname subdirectory and if it doesn't exist, create it. Bad things happen if you run the script without the directory already being present.
find quote
theophile Offline
Fan
Posts: 569
Joined: Jan 2009
Reputation: 30
Post: #15
outleradam Wrote:Then I moved the hdpvr cutter from mythtv to the file dir and I reset the job as ../hdpvrcutter title subtitle again.Angry Then I tried running the job manually Angry Then I tried running the job manually as rootAngry Then after 4 hours I gave up Angry

sorry, i had to split the post up because there were too many smileys.
As I'm sure you are aware, console output is necessary for debugging a script. What do you get on the command line when you run:

Code:
./hdpvrcutter "Show Name" "Episode Name"
find quote
outleradam Offline
Member+
Posts: 1,722
Joined: Sep 2009
Reputation: 20
Location: Louisiana
Post: #16
currently thetvdb.com is down.....
Code:
adam@adam-desktop:~$ /home/adam/Desktop/hdpvrcutter.pl "South Park" "Here Comes the Neighborhood"
Original airdate: 2001-11-28
Recorded Date: 2009-12-01
Searching THE-TV-DB for series 'South Park'
About to call GET HTTP url: 'http://www.thetvdb.com/api/GetSeries.php?seriesname=South Park'
Failed to get response! Status '500 Can't connect to www.thetvdb.com:80 (connect: timeout)'
Can not locate series 'South Park' in THE-TV-DB.
About to call GET HTTP url: 'http://www.thetvdb.com/api/GetEpisodeByAirDate.php?apikey=259FD33BA7C03A14&seriesid=&airdate=2001-11-28'
Failed to get response! Status '500 Can't connect to www.thetvdb.com:80 (connect: timeout)'
Use of uninitialized value $E in concatenation (.) or string at /home/adam/Desktop/hdpvrcutter.pl line 327.
2009-12-02 23:15:39.138 Illegal option: '--getcutlist-avidemux' (use --help)
mkvmerge v2.9.8 ('C'est le bon') built on Aug 19 2009 16:59:31
Error: The source file '/var/lib/mythtv/recordings/organized/South Park.SE.Here Comes the Neighborhood.avi' could not be opened successfully, or retrieving its size by seeking to the end did not work.
rm: cannot remove `/var/lib/mythtv/recordings1056_20091201200000.mpg.idx': No such file or directory
rm: cannot remove `/var/lib/mythtv/recordings/temp.proj': No such file or directory
rm: cannot remove `/var/lib/mythtv/recordings/organized/South Park.SE.Here Comes the Neighborhood.avi': No such file or directory

Use mythicalLibrarian to make a library out of your MythTV files. Leave the recording to MythTV and use XBMC as your library.
Installation and Instructions:http://wiki.xbmc.org/index.php?title=MythicalLibrarian
Technical Support:http://forum.xbmc.org/showthread.php?tid=65644
[Image: newsig-1.png]
[url=http://forum.xda-developers.com/showthread.php?tid=1081892][/url]
find quote
theophile Offline
Fan
Posts: 569
Joined: Jan 2009
Reputation: 30
Post: #17
outleradam Wrote:currently thetvdb.com is down.....
Code:
adam@adam-desktop:~$ /home/adam/Desktop/hdpvrcutter.pl "South Park" "Here Comes the Neighborhood"
Original airdate: 2001-11-28
Recorded Date: 2009-12-01
Searching THE-TV-DB for series 'South Park'
About to call GET HTTP url: 'http://www.thetvdb.com/api/GetSeries.php?seriesname=South Park'
Failed to get response! Status '500 Can't connect to www.thetvdb.com:80 (connect: timeout)'
Can not locate series 'South Park' in THE-TV-DB.
About to call GET HTTP url: 'http://www.thetvdb.com/api/GetEpisodeByAirDate.php?apikey=259FD33BA7C03A14&seriesid=&airdate=2001-11-28'
Failed to get response! Status '500 Can't connect to www.thetvdb.com:80 (connect: timeout)'
Use of uninitialized value $E in concatenation (.) or string at /home/adam/Desktop/hdpvrcutter.pl line 327.
2009-12-02 23:15:39.138 Illegal option: '--getcutlist-avidemux' (use --help)
mkvmerge v2.9.8 ('C'est le bon') built on Aug 19 2009 16:59:31
Error: The source file '/var/lib/mythtv/recordings/organized/South Park.SE.Here Comes the Neighborhood.avi' could not be opened successfully, or retrieving its size by seeking to the end did not work.
rm: cannot remove `/var/lib/mythtv/recordings1056_20091201200000.mpg.idx': No such file or directory
rm: cannot remove `/var/lib/mythtv/recordings/temp.proj': No such file or directory
rm: cannot remove `/var/lib/mythtv/recordings/organized/South Park.SE.Here Comes the Neighborhood.avi': No such file or directory
The reason the script is bailing on you (even when TVDB is up) is that you didn't patch mythcommflag, which the wiki lists as the first requirement. Since that's needed for transcoding and you're not going for that, you can just change the script and ignore that.

So go to the end and look at the last few lines:

Code:
exec "mythcommflag --getcutlist-avidemux -f \"$filename\" --outputfile \"$recordings_dir\"/temp.proj;
nice -n 9 avidemux2_cli --force-alt-h264 --autoindex --rebuild-index --nogui --force-smart --load \"$filename\" --run \"$recordings_dir\"/temp.proj --save \"$output_dir\"/\"$outfile\.avi\" --quit 2> /dev/null;

# Move the AVI file into a Matroska.  
# Failure to do this will result in broken seeking.

mkvmerge -o  \"$output_dir\"/\"$outfile\.mkv\"  \"$output_dir\"/\"$outfile\.avi\";

# Do a little cleanup.

rm \"$filename\".idx \"$recordings_dir\"/temp.proj \"$output_dir\"/\"$outfile\.avi\""

This is the part that actually performs the file operation. For testing purposes, go ahead and remove these lines entirely and replace them with this:

Code:
exec "echo I would create a new file called: \"$output_dir\"/\"$outfile\.mpg\""

You can change the "mpg" to whatever file extension your source files are. This won't do anything to the filesystem, just tell you what it thinks the output file should be called. If this works (it should now that TVDB is back up), then you just need to decide whether you want to symlink to the original file, or actually change the name of the source file and use mythrename.pl to update the MythTV database with the new filename. Either method will require an extra line or two, but should be pretty easy.

One observation: my original application did not include modifying the mythconverg database, so the limitation regarding episodes that aired on the same day becomes more problematic in that case. If you simply symlinked the new file to the original, it would be trivial to manually change the filename in the case of an error. If you used mythrename.pl to change the Myth database, you'd also have to manually change the DB if/when this happens.
find quote
outleradam Offline
Member+
Posts: 1,722
Joined: Sep 2009
Reputation: 20
Location: Louisiana
Post: #18
My program is designed to work with mythrename to change the database. Basically it will be mythrename $outputFromBashSExx. I think this should work. Eventually this .sh will be part of a larger multiple scraper application.

Mythrename can be executed again from the webadmin after making changes to the BashSExx showname interperator.

Btw. The standard for tvdb use includes keeping a local db. If you do not, you overtax their servers. They can shut off your apikey if it becomes problematic. It is a simple curl grep to verify if the local db needs update.

Use mythicalLibrarian to make a library out of your MythTV files. Leave the recording to MythTV and use XBMC as your library.
Installation and Instructions:http://wiki.xbmc.org/index.php?title=MythicalLibrarian
Technical Support:http://forum.xbmc.org/showthread.php?tid=65644
[Image: newsig-1.png]
[url=http://forum.xda-developers.com/showthread.php?tid=1081892][/url]
(This post was last modified: 2009-12-03 20:26 by outleradam.)
find quote
theophile Offline
Fan
Posts: 569
Joined: Jan 2009
Reputation: 30
Post: #19
outleradam Wrote:My program is designed to work with mythrename to change the database. Basically it will be mythrename $outputFromBashSExx. I think this should work. Eventually this .sh will be part of a larger multiple scraper application.

You could also call mythrename.pl from within the script to affect only the recording specified. That way you can automatically run the script as a user job on every recording, ensuring that recordings are renamed/updated as they're made rather than at specified intervals as in a cron job. It would also prevent unnecessary operations on files created by the ringbuffer when watching live tv.
find quote
outleradam Offline
Member+
Posts: 1,722
Joined: Sep 2009
Reputation: 20
Location: Louisiana
Post: #20
the ring buffer gets processed by local mythtv jobs?

interesting.. does the ring buffer get show squeezed? I'm transferring from windows BTV and I don't know the proper term.. show squeeze = when you record a show in mpg format, then compress it to avi or wmp.

This program, when finished, will only output "SxxExx" So, if the rename fails, it will still be moved and renamed showname/epname. This program is not designed to work independently. It will either get the information, or fail quietly. I think that's the proper way of doing it.

Either way, I don't want recordings on the HD. They need to go on my NAS, which will be mounted to the optimized folder after show squeeze so that I can maintain a rotating library.

Use mythicalLibrarian to make a library out of your MythTV files. Leave the recording to MythTV and use XBMC as your library.
Installation and Instructions:http://wiki.xbmc.org/index.php?title=MythicalLibrarian
Technical Support:http://forum.xbmc.org/showthread.php?tid=65644
[Image: newsig-1.png]
[url=http://forum.xda-developers.com/showthread.php?tid=1081892][/url]
(This post was last modified: 2009-12-03 20:56 by outleradam.)
find quote