0

My first post here, so please if this topic is answered elsewhere let me know. I found similar posts but didn't manage to use them to solve my problem.

Background: I use a IPTV service provider which offers the possibility to watch TV Channels on my RPi running KODI. SO this provider promotes usage of a IPTV Simple Client together with some playlist urls. Making thinks shorter, this playlists are generated for my account only and are bound to my public IP address. Problem, I don't have and want to have a fix Public IP address, so everytime my ISP resets my DSL connection I have to login on the IPTV provider page and press on a so called "Update IP" button. That's annoying!! I want to automate that with a bash script which would be triggered by my dynamic dns service update which runs on a regular basis on my rpi.

What I managed so far: - use a bash command with CURL to login on the webpage and save the cookie into a text file. with this:

 curl -c cookie.txt -d "user=mymail@mail.com" -d "pass=mypass" http://www.spicetvbox.ro/user/login

And then I tried several ways to press that "Update IP" button with:

 curl -b cookie.txt  -d "press=UPDATEIP" http://www.spicetvbox.ro/user/xbmc
 curl -b cookie.txt  -d "button=Upfate IP" http://www.spicetvbox.ro/user/xbmc
 curl -b cookie.txt -X POST   http://www.spicetvbox.ro/user/xbmc

And allot of other commands like this. I tried to use firebug to inspect the button element.. and this is the html from firebug:

<form id="formXBUpd89942" class="jqValidation" role="form" novalidate="novalidate" action="http://www.spicetvbox.ro/user/xbmc" method="post">
<input type="hidden" value="UPDATEIP" name="run">
<input type="hidden" value="89942" name="id">
<button class="btn btn-info btn-xs" type="submit">
<i class="fa fa-refresh"></i>
  Update IP
</button>

Please give me some advice on how to press that button from CURL.

luci84tm
  • 3
  • 1
  • 2

1 Answers1

1

You don't really need to click the button - you need to submit the form, or at least achieve the same effect.

Use cURL to do an HTTP POST to http://www.spicetvbox.ro/user/xbmc - something like this:

curl -b cookie.txt --data "run=UPDATEIP&id=89942" http://www.spicetvbox.ro/user/xbmc

This data is taken from the value of the form fields and the URL is taken from the action attribute of the form element. When --data (equivalent to -d) is specified, cURL performs a POST.

Tom Fenech
  • 72,334
  • 12
  • 107
  • 141
  • If you're having issues running curl (and can reliably reproduce them), perhaps that should be a separate question, although without more detail I'm not sure how I or anyone else will be able to help you... – Tom Fenech Jul 02 '15 at 14:25
  • 1
    You are right, sorry for not providing to many details..I will try to troubleshoot it my self and if I don't manage I'll post a new question. Thanks a lot, Tom Fenech you made my day :D – luci84tm Jul 02 '15 at 15:51