Page 1 of 1

Import Recorder, best way to schedule?

Posted: Sun May 06, 2018 6:31 am
by sfatula
So, I have created an import recorder. I have some content I want to download from a website, I scrape it (public domain), download it, and then want to use the import recorder. Everything is done, except, scheduling!

The issue here is there seems to be no good way to know when a given days recording will be available. Sometimes, a given day is delayed by a day even. So, my workflow is:

1. I have a standalone program that scans the site, looking for new recordings that I do not already have. The site only has the last 5 shown, and, there is a unique id for each episode. Therefore, I know if I have downloaded a given episode before. So, I might get todays only, or, I might get todays and yesterdays, who knows. The first run, I will get all 5.
2. So, now I have downloaded the content, decided to store this locally outside of the import recorder logic for various reasons. I have a directory with all downloaded but unimported episodes.
3. Now, I want the import recorder to be triggered. Near as I can tell, the only way to do that is via the guide and a schedule? I could add a manual single recording rule, but, that's not good as every episode ever will have a new rule. And, I want to keep only a certain number. I might have only 1 to import today, or, I might have 2-5.

So, for point 3 above, what is a good way to trigger the recording so the import recorder will run a variable number of times for today? Do I really have to incorporate into the guide service the schedule? So, maybe update it to add 4 recordings today if that's what I have? There apparently is no API to add an entry into the guide, so, I suppose I have to append to the schedule file I have and then import the schedule again? Is there a better way?

Re: Import Recorder, best way to schedule?

Posted: Sat May 19, 2018 9:11 am
by mythrec
If you want to do it with the Import Recorder then afaik you will need to create a tv grabber to do it properly. I believe mythtv can use any executable that starts with tv_grab in the file name to supply guide data. If you do a web search on xmltv I'm sure you'll find some details on how this works or you can just manually run a working grabber and copy the format. You will need to dummy up some of the fields e.g. start time, end time etc and the rest of the data should come from your scraper. You will need to find your own way to track the id, this could be done using an additional table in the mythtv database or you could add it to the description or even the subtitle if it is truly unique. You obviously would also need to setup a new source and a dummy channel associated with the source so you can actually schedule things (you also need to fill in the xmltvid to associate the channel and guide data) . An appropriate recording rule would then pickup each new show provided you have a consistent subtitle / description for each show. You would then need to setup a system event to do the actual import, you may be able to stream them straight in to the target file especially in conjunction with ffmpeg. This should give a consistent view in the recording list and would ensure all the appropriate tables in mythtv are updated.

The alternative is to bypass mythbackend entirely and update the mysql tables directly although you need to be sure you are not going to stuff something up if you do that. You should still really setup a dummy channel and recording schedule for this and also to improve the way it appears in the recording list. The quick and dirty way is to just add an entry in the 'recorded' table but I guess you would be on your own if you break something doing that. I'm not sure if the backend will expire recordings doing it this way, you would at least need the recording schedule setup and associated to have any hope of it working. Not sure how badly it can go wrong if you're manually editing stuff like this though. I actually just finished some scripts that import from my dvd changer so I may upload these at some point. Not much sense having some shows split between mythvideo and recordings especially as duplication detection doesn't cover both and it's just plain messy (a few shows have gone off the air and come back at some point or other).

I use both the above methods so I believe you could get either to work depending on your needs.

Re: Import Recorder, best way to schedule?

Posted: Sat May 19, 2018 3:22 pm
by sfatula
Thank you for confirming my suspicions. I will likely use the former as I want to avoid updating tables where possible (though that's what I did for a living, would just rather do it the official way). When I get back from Spain and the Canary Islands, will complete the coding to add the schedule and on to testing since the rest works.

Thanks again for the information.