azlm8t / tv_grab_az_sdjson_sqlite

XMLTV grabber for Schedules Direct JSON service
GNU General Public License v2.0
9 stars 1 forks source link

Not an issue, just thanks #1

Open Ixian opened 5 years ago

Ixian commented 5 years ago

I really appreciate the work you've done on this. It was exactly what I was looking for for SD/Tvheadend. So far, so good :)

Can you recommend a way to build in channel filtering? I'm writing a script to pull channels from my hdhr and put them in an m3u file that's formatted so tvh imports them correctly and it would be cool to combine with this so the grabber only pulls data from the channels in the m3u. It looks like I can do a regex exclude similar to how you specify certain channels to pull extra data from but appreciate any additional pointers you might have?

azlm8t commented 5 years ago

Thanks. Sorry I didn't see your comment earlier, I didn't get any notification for some reason.

There is a "--channel-regex" option and a "--channel-exclude-regex" option.

So, the way I do it is to add "--channel-regex='BBC|YYY|ZZZ'". The | symbol means "or" for a regular expression so it means the channel must contain the string BBC or YYY or ZZZ. The exclude version does the opposite so it would mean it must not contain BBC and must not contain YYY and must not contain ZZZ. So the generated xmltv file only contains the information for those channels.

Hope that helps?

I'm not sure of the exact format of your m3u, but perhaps that info might be enough to get started?

If your channel names are at a fixed column in the m3u (such as always starting 5 characters in and always prefixed with some fixed string) then it might be relatively easy to auto-generate it (assuming you have several hundred channels). If you put an example of a couple of lines (edit out anything like passwords or IP addresses) and I may be able to help.

azlm8t commented 5 years ago

I've seen an example m3u like this:

#EXTINF:0 channelID="x-ID.84" tvg-chno="1093" tvg-name="RTL" tvg-id="1093" tvg-logo="https://s3.amazonaws.com/schedulesdirect/assets/stationLogos/s52564_h3_aa.png" group-title="Test",RTL

If this is like yours, then perhaps the following will help:

grep tvg-name /tmp/sample.m3u | sed 's/.*tvg-name=//' | awk -F'"' '{print $2}' | paste -s -d '|' /dev/stdin

...where /tmp/sample.m3u is your saved m3u file, and then it will output a string such as RTL|YYY|ZZZ.

I'm assuming your channel names are mostly just text and don't contain "odd" characters (one of my channels used to contain '&' which messed up a lot of scripts). Also, technically the strings should all be "anchored" (so if you wanted RTL but not RTL2 then the above regex would get both), but it should be good enough I hope.

I can't guarantee that will work on all systems since some have versions of the commands that don't implement everything correctly.

Just remember that because the output contains "|" symbols (which your shell might re-interpret), you might need to put single quotes (') or double quotes (") around the string when you use it after the --channel-regex. So --channel-regex='ABC|DEF' and not --channel-regex=ABC|DEF.

If it doesn't work then let me know what it output.