Epg offset tutorial by @ravstar

There are 137 replies in this Thread which was already clicked 18,114 times. The last Post () by k3k.

  • Not tried this, as I have no offsets to check against at the moment.

    But a few tweaks will be needed. And yes I know this is very new and tweaks will come.


    Firstly I am confused why it would take 10-60 mins to perform the text swap? Even with a large provider, it shouldn't be that slow.


    in xmltv.sh your are looking for +0000 - It won't always be +0000, depending on provider or where it has originally sourced its epg from. Could be +0100, +0500 etc.
    sed -i '/+0000/ s//time/g' /media/hdd/epg/iptvepg.xml

    you seem to be gzipping this after its finished. That shouldn't be required. The xml would be fine to read.
    This is a local file, so probably no need to compress. Unless you are doing for space saving


    Why are you creating new epg source files. You can use the exisiting source files in epgimporter folder, and change the url reference in there instead to the local xmltv file rather than the external url ref. As long as the script is run after jedi update this will not be a problem

    That way you will not run into issues with multiple providers.

    ** A person who feels appreciated will always do more than what is expected **

  • Hi KiddaC


    Thank you for your response.


    Firstly I am confused why it would take 10-60 mins to perform the text swap? Even with a large provider, it shouldn't be that slow.

    I tried different sed commands but in whole it is taking the time only in providers xml as reason could be unmanaged data that is long lines rather than many lines. Though in other sources it replace the data very quickly.


    in xmltv.sh your are looking for +0000 - It won't always be +0000, depending on provider or where it has originally sourced its epg from. Could be +0100, +0500 etc.

    You are right this could be anything but as you know this is very first version of it so I will add multiple possibilities so it should replace range +/-0030 to +/-1000

    sed -i '/+0000/ s//time/g' /media/hdd/epg/iptvepg.xml

    you seem to be gzipping this after its finished. That shouldn't be required. The xml would be fine to read.

    This is a local file, so probably no need to compress. Unless you are doing for space saving

    Yes only to save the space so a 40mb xml gets compressed to 6mb.


    Why are you creating new epg source files. You can use the exisiting source files in epgimporter folder, and change the url reference in there instead to the local xmltv file rather than the external url ref. As long as the script is run after jedi update this will not be a problem


    The setup script creates file only once but I can add this step in xmltv script that runs everyday. Another Idea came in my mind to replace provider url for all files in epgimport directory so no matter if you have created bouquets with Jedimaker it would work with echannilizer and e2m3uboquotes too but again people have to set the update time for all bouquet makers to run before 6:00am.


    That way you will not run into issues with multiple providers.

  • Its been a while since I wrote any bash scripts. I will copy your code onto my github and have a play.
    Especially around your use of sed. Might be better using awk.

    Might take some time for me to get up to speed again though.


    I could actually do this in the jedi plugin... But thats no fun ;)

    ** A person who feels appreciated will always do more than what is expected **

  • ravstar


    Been having a play with this in windows with local files.

    Here are some experiments. Note this isn't your final script just some food for thought for you.


    ** A person who feels appreciated will always do more than what is expected **

  • ravstar


    Been having a play with this in windows with local files.

    Here are some experiments. Note this isn't your final script just some food for thought for you.


    Thank you KiddaC great help.


    Me being a layman with no knowledge of writing script this is great help. I will fine tune it and figuring out if +0000 is not the case then add some additional if commands so we can change whatever is there instead of +0000 with time difference required.

  • the +0000 is difficult in shellscripts to covert to a number add offset and then convert back to +0100 etc.

    I googled it to death and didn't find a simple answer yet. + / - is a problem.


    And note... I edited my code in my post. The last line was incorrect. It needs to change to the gz file not xml. (now amended)

    ** A person who feels appreciated will always do more than what is expected **

  • the +0000 is difficult in shellscripts to covert to a number add offset and then convert back to +0100 etc.

    I googled it to death and didn't find a simple answer yet. + / - is a problem.


    And note... I edited my code in my post. The last line was incorrect. It needs to change to the gz file not xml. (now amended)

    agree with your +0000 comment even I am searching for a solution since then. Though I think we can add some conditions based on two values let’s say if var1=+0230 (original time) var2=-0100 (the difference needed) then sed +0230 with +0130

    But again there will be series of if commands 😛

  • I just notcied the errors of my ways.

    If we change the source file, url with local file address.

    Then you cant get the details again.

    As I said though, I was only experimenting. Not a finished script.

    ** A person who feels appreciated will always do more than what is expected **

  • I just notcied the errors of my ways.

    If we change the source file, url with local file address.

    Then you cant get the details again.

    As I said though, I was only experimenting. Not a finished script.

    KiddaC Yes already noticed so we need to have second script for sure, I am already working on it.

    grep -oP doesn't work either so made below changes and it all working.


    time change sed command taking same time even with wget "${url}" -O -| sed -e "s|+0000|$time|g" > ${xmltvfilename}

    hence I changed it with below.


    #!/bin/sh

    #

    workdir="/media/hdd/epg"

    epgimport="/etc/epgimport"

    filename="jmx.iptv.sources.xml"

    time="-0100"

    if [ ! -d "${workdir}" ]; then

    mkdir -p "${workdir}"

    fi

    source="${epgimport}/$filename"

    # get url from source file

    url=$(grep -o 'http.*$' /etc/epgimport/jmx.iptv.sources.xml | cut -f 1 -d ']')

    echo $url

    #get name from source file, remove illegal file characters with underscore and make lower case

    name=$(grep -o 'catname=.*$' /etc/epgimport/jmx.iptv.sources.xml | cut -c10- | cut -f 1 -d '"' | \

    sed -e 's|<|_|g; s|>|_|g; s|:|_|g; s|"|_|g; s|/|_|g; s|\\|_|g; s/|/_/g; s|?|_|g; s|*|_|g; s| |_|g')

    echo $name

    #download xmltv file (xmltv.sh) to filename $xmltvfilename - replace old time with new time

    xmltvfilename="${workdir}/${name}.xml"



    echo "Downloading EPG data..."



    wget -O ${xmltvfilename} "${url}"


    echo "CORRECTING TIME. PLEASE WAIT, IT WOULD TAKE BETWEEN 10-50 MINUTES SO BE PATIENT..."



    sed -i '/+0000/ s//time/g' ${xmltvfilename}


    gzip -f ${xmltvfilename} > ${xmltvfilename}.gz

    #replace source - double quotes required for sed to convert variables.

    sed -i "s|$url|${xmltvfilename}.gz|g" $source


    echo "All done! go to epgimpoter, Look for option named 'Clearing current EPG before import' and turn it to yes and Import EPG manually by pressing yellow button"

  • Watching football at the moment.
    Really annoyed with myself the other night, I was using an online shellscript editor, I had just finished all my code for replacing the timezone value, then I accidentally hit the browser back button at lost all my code. :crying: It was good code to that I had spent about an hour working out.

    ** A person who feels appreciated will always do more than what is expected **

  • Watching football at the moment.
    Really annoyed with myself the other night, I was using an online shellscript editor, I had just finished all my code for replacing the timezone value, then I accidentally hit the browser back button at lost all my code. :crying: It was good code to that I had spent about an hour working out.

    Oh No! I can understand how it feels..

  • ravstar , yes will chack script and give feedback.

    You mention if using auto run setting in Jedimaker Xtream, setting time to auto run before the script what about autobouquetsmaker does it matter at the moment I have script first ,ABM, Jedimaker, then Epgimporter in that order.

  • ravstar , yes will chack script and give feedback.

    You mention if using auto run setting in Jedimaker Xtream, setting time to auto run before the script what about autobouquetsmaker does it matter at the moment I have script first ,ABM, Jedimaker, then Epgimporter in that order.

    No rest doesn't matter only jedimakerextreme is what you have to set to update before 5:30am

  • ravstar , when I came in tonight I had no IPTV EPG I did have satellite EPG what I did notice was there where two cron timers one for 6.00 am and other for 5.59 am.

    So I think new script did not delete old cron timer I have deleted old cron timer and just manually ran new one after I ran jedimaker IPTV bouquets are now as now normal with correct timeshift for the one I select.

  • ravstar , when I came in tonight I had no IPTV EPG I did have satellite EPG what I did notice was there where two cron timers one for 6.00 am and other for 5.59 am.

    So I think new script did not delete old cron timer I have deleted old cron timer and just manually ran new one after I ran jedimaker IPTV bouquets are now as now normal with correct timeshift for the one I select.

    Yes, I forgot to tell you to manually remove the old cron by going into menu>timer>cron timers As if I add that in my script to remove the cron then there is possibility that it remove all crons for users who are running the script for first time so I have now added this step in instructions. Thank you for highlighting this.


    It should now update fine tomorrow morning. :wink:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!