1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Anyone write Scripts ?

Discussion in 'Zgemma-Star' started by stevebrooks, Mar 13, 2017.

  1. stevebrooks

    stevebrooks Member

    Is it possible to write a script ( .sh ) to delete a bouquet ? If so how easy/hard would it be ?...
    The reason why.

    1/ I have a script from my IPTV provider that I have added to cron manager. it runs daily @ 0800. The problem is, it adds a duplicate bouquet every day.
    2/ My plan is to delete old IPTV bouquet at 07.55 via cron, Then when updated script runs @ 0800 I don't end up with duplicate IPTV bouquets.

    I could delete old bouquet manually every day but that's a pain !
  2. Willo3092

    Willo3092 TK Veteran Forum Supporter

    I'm not sure where IPTV bouquets are kept but assuming they are in the same place as TV bouquets this might work:

    rm -rf /etc/enigma2/name of bouquet
    bangord30 likes this.
  3. dsayers2014

    dsayers2014 TK Veteran

    Mine dont create new bouquets they overwrite them but my provider scripts run on boot rather than daily
  4. moshibeth

    moshibeth TK Veteran

    iptv bouquets are added when you are given a m3u type by by your provider,When you add it to your box it could be just one long list of channels,You can create your own lists and put them where you like using esettings+
  5. dsayers2014

    dsayers2014 TK Veteran

    We are on about adding them via script so the m3u is added and converts to bouquet daily

    Sent from my SM-G925F using Tapatalk
  6. dsayers2014

    dsayers2014 TK Veteran

    This is thanks to tommycahir

    Setting up and configuring the shell script
    • Download the attachment autobouquet.zip

    • Edit the autobouquet.sh file to point to your m3u file using your xml editor.
      - Note If your IPTV provider uses a username and password in URL to redirect to a download then you need to install CURL and use the 2nd command to get your file. Directions on using this in the .sh file itself
    • Change the parameter for the python script to whatever type of IPTV your provider is using. I have defaulted to Gstreamer here but if that doesn't work then choose another and rerun until one works for you, it must be exactly as per below options.
      - The options available are: LiveStreamerhls or LiveStreamerhlsvariant or Gstreamer or Multicast
    • FTP both of these files to your box to the /usr/script/ folder
    • Set the permissions on the autobouquet.sh file to 755 using your FTP client (right click properties in filezilla) or chmod 755 autobouquet.sh from the SSH command line.
    • If you want to manually run the script to test it then open a SSH connection and change directory using "cd /usr/script/" then run "./autobouquet.sh"

    Setting up the automated task to run the script - SSH method
    • Open an SSH session to you enigma2 device.
    • On the command line run the below command to open the crontab

      crontab -e

    • Once this opens press i to switch to INSERT mode (seen at bottom of the screen)
    • Add the following command to the crontab, this can be done by hitting cntrl +v or retyping.
      - This will run the command to download the m3u file @ 5:30am every day and the output will be stored in the folder specified.

      30 05 * * * cd /usr/script/ && ./autobouquet.sh
    • Now hit ESC followed by :wq and this will exit the crontab editor and save the entry. (q=quit w=write)
    • To check if the new entry to the cron was successful then run the below and you should see the same detail as you entered

      crontab -l

    Setting up the automated task to run the script - Box GUI method
    • On your box remote go to Menu->Timers->CronTimers
    • In the CronTimers screen click the green button to Add a new timer
    • Set it to run daily and set the desired time for it to run
    • In the command Type choose predefined
    • In the command to run field press right or left until you come to autobouquet.sh
    • Click the green button to save the new timer and now your m3u will be extracted each day and the bouquet will be refreshed also.
    • You should ensure that autostart is set to active also


    Attached Files:

    Last edited: Mar 14, 2017
    bangord30 and Willo3092 like this.
  7. stevebrooks

    stevebrooks Member

    My script also runs on boot, but adds another bouquet each time it boots. does yours over right the existing bouquet ?
    if so how do i get mine to do that ?
    PS my bouquets are all named N/A
  8. stevebrooks

    stevebrooks Member

    This guide by tommycahir looks amazing,.. If i could only understand it. :).
    I have just come from an Openbox, sorry.. I am in the early stages of understand this tech. There seems to be loads of people willing to help with this, Cheers from a beginner eager to learn.
  9. dsayers2014

    dsayers2014 TK Veteran

    All my bouquets have names on them so that probably why it overwrites them if yours has na that's probably why you have repeated bouquets.. Maybe best speaking to your provider
  10. glyn1978

    glyn1978 Member

    I use a crontimer to run a .sh script everyday to update my IPTV bouquet.

    The command in the .sh file is the following

    wget -O /etc/enigma2/iptv.sh "http://IPTVADDRESS.net:PORT/get.php...SSWORDHERE&type=enigma22_script&output=mpegts"
    chmod 777 /etc/enigma2/iptv.sh

    Obviously you need to change the these parts to suit your own account. Also note that the address quoted above has be truncated so you will need to be aware of that. (Ill upload the .sh file as a txt file and you can edit and convert etc)

    then save your .sh file (I called mine giptv.sh) and ftp'd it to the following location


    Then i connected to the zgem with putty and executed the following commands to setup the crontimer via putty and not via the remote control etc.

    ipkg update
    ipkg install nano

    crontab -e

    5 */12 * * * /usr/script/giptv.sh >/dev/null 2>&1

    cd /usr/script

    chmod 777 giptv.sh

    ls -l (this is just to check that the chmod has worked correctly and the file is readable, writable and executable)

    Hope you can make some sense of this. I played around for a while to try and get this to work, and this solution did it for me, my IPTV bouquet updates at 5mins past the hour every 12 hours, turns out the thing i was doing wrong at first was forgetting the chmod 777 part.

    Attached Files:

    bangord30 and dsayers2014 like this.
  11. stevebrooks

    stevebrooks Member

    Thanks Glyn1978 for your help, I am able to follow your steps up to editing and uploading .sh file. But then im not sure how to get commands into putty.

    ipkg update ok
    ipkg install nano ok
    crontab -e ok

    After this point I'm not sure how to proceed with or how to get this into putty.
    5 */12 * * * /usr/script/giptv.sh >/dev/null 2>&1

    Any help would be welcomed.
  12. dsayers2014

    dsayers2014 TK Veteran

    Try via the menu's with job manager
  13. stevebrooks

    stevebrooks Member

    I can run the script from there ok, but it still adds another bouquet to the list, not updating the current bouquet.
    All of the bouquets the script generates are also named N/A. I must be doing something wrong.
  14. dsayers2014

    dsayers2014 TK Veteran

    With the tut on post 6 you can choose what name the m3u gets called so it's IPTV.m3u you can rename IPTV to what you want.

    Give it a try you should only need to change the link on line 5 in the autobouquets.sh the autobouquets.py then converts it to bouquets
    bangord30 likes this.
  15. stevebrooks

    stevebrooks Member

    I'm just not getting it dsayers2014 sorry. I'm trying to follow tommycahir's guide step by step, but i dont understand this :
    - Note If your IPTV provider uses a username and password in URL to redirect to a download then you need to install CURL and use the 2nd command to get your file. Directions on using this in the .sh file itself
    My link does contain user/pass,
  16. dsayers2014

    dsayers2014 TK Veteran

    Try without installing curl. I think it's if it doesn't point straight to the m3u but if your link ends in .m3u it should work if not we can move on to editing the script to install curl

    Sent from my SM-G925F using Tapatalk
  17. stevebrooks

    stevebrooks Member

    Cheers dsayers2014 I'll give this ago later, the boss whats me to take her shopping :-(
    On another note, I've just received a H2H and will be flashing with your image later. I hope it goes as well as flashing my H2S with woosh.
  18. glyn1978

    glyn1978 Member

    So when (using putty) uve ran the command contab -e in putty it opens up the cronatab editor. Then if you copy the crontimer code above (5 */12 * * * /usr/script/giptv.sh >/dev/null 2>&1) and right click in the editor it pastes it.

    Then use ctrl X to exit and it will ask if want to save so press Y

    You should now be back into normal putty screen and you can run the other commands to chmod the file etc.

    Then when you look on ur zgem in conrtimers you should have one set to run the script at the desired frequency.
    bangord30 likes this.
  19. stevebrooks

    stevebrooks Member

    Do I have to edit the autobouquets.py file ?
  20. stevebrooks

    stevebrooks Member

    I have now followed all the steps from your guide, and the bouquet stills shows up as N/A. !
    Also did not over right previous bouquet !
    IMG_2561.jpg IMG_2562.jpg

    Attached Files:

Share This Page