NextPVR Forums
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Support v
« Previous 1 … 5 6 7 8 9 … 34 Next »
Simulate old CommandLineOptions

 
  • 0 Vote(s) - 0 Average
Simulate old CommandLineOptions
damo
Offline

Junior Member

Posts: 23
Threads: 6
Joined: Sep 2018
#1
2019-08-14, 05:57 AM
Hi,

Just wondering if there is a way of using the old command line options (-updateepgonly) with V5? When ever I try with the windows client, it runs the client and doesn't update the EPG.
Can we have an hourly schedule to grab the EPG data?

I'm using xmltv and Foxtel data changes all the time.
JavaWiz
Offline

Posting Freak

Jacksonville, FL. USA
Posts: 2,522
Threads: 141
Joined: Dec 2006
#2
2019-08-14, 09:56 PM
You could probably do it thru the WebAPI interface, the call is:

http://localhost:8866/services/service?m...ormat=json

However you need to setup a session first, get a token and provide the right data in the request headers.
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 45,346
Threads: 868
Joined: May 2006
#3
2019-08-14, 11:53 PM
Here is some rough python code extracted from knewc to do this with the security that sub expects us to use on localhost but it should work anywhere on your local LAN.

Code:
from urllib.request import urlopen,Request
import json
import sys


ip = "127.0.0.1"
port = 8866
pin = "0000"
sid = ""

def doRequest5(method, isJSON = True):
    retval = False
    getResult = None
    url = "http://" + ip + ":" + str(port) + '/service?method=' + method
    if (not 'session.initiate' in method):
        url += '&sid=' + sid
    print(url)
    try:
        request = Request(url, headers={"Accept" : "application/json"})
        json_file = urlopen(request)
        getResult = json.load(json_file)
        json_file.close()
        retval = True
    except Exception as e:
        print(str(e))

    return retval, getResult

def hashMe (thedata):
    import hashlib
    h = hashlib.md5()
    h.update(thedata.encode('utf-8'))
    return h.hexdigest()


def  sidLogin5():
    method = 'session.initiate&ver=1.0&device=emby'
    ret, keys = doRequest5(method)
    global sid
    if ret == True:
        sid =  keys['sid']
        salt = keys['salt']
        method = 'session.login&md5=' + hashMe(':' + hashMe(pin) + ':' + salt)
        ret, login  = doRequest5(method)
        if ret and login['stat'] == 'ok':
            sid =  login['sid']
        else:
            print ("Fail")
    else:
        print ("Fail")

def main(method):
    sidLogin5()
    doRequest5(method)

if __name__== "__main__":
    main(sys.argv[1])

Save as filename.py edit in your pin at the beginning and run it with

python filename.py system.epg.update

Martin
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 102,403
Threads: 742
Joined: Nov 2003
#4
2019-08-15, 02:30 AM
I've added an NScriptHelper utility for the next build, which will support "-updateepg" and other stuff
damo
Offline

Junior Member

Posts: 23
Threads: 6
Joined: Sep 2018
#5
2019-08-16, 06:10 AM
sub Wrote:I've added an NScriptHelper utility for the next build, which will support "-updateepg" and other stuff

Champion... Will wait for then.
sfiorini
Offline

Junior Member

US
Posts: 3
Threads: 1
Joined: Feb 2022
#6
2022-03-16, 08:05 PM
(2019-08-14, 11:53 PM)mvallevand Wrote: Here is some rough python code extracted from knewc to do this with the security that sub expects us to use on localhost but it should work anywhere on your local LAN.

Code:
from urllib.request import urlopen,Request
import json
import sys


ip = "127.0.0.1"
port = 8866
pin = "0000"
sid = ""

def doRequest5(method, isJSON = True):
    retval = False
    getResult = None
    url = "http://" + ip + ":" + str(port) + '/service?method=' + method
    if (not 'session.initiate' in method):
        url += '&sid=' + sid
    print(url)
    try:
        request = Request(url, headers={"Accept" : "application/json"})
        json_file = urlopen(request)
        getResult = json.load(json_file)
        json_file.close()
        retval = True
    except Exception as e:
        print(str(e))

    return retval, getResult

def hashMe (thedata):
    import hashlib
    h = hashlib.md5()
    h.update(thedata.encode('utf-8'))
    return h.hexdigest()


def  sidLogin5():
    method = 'session.initiate&ver=1.0&device=emby'
    ret, keys = doRequest5(method)
    global sid
    if ret == True:
        sid =  keys['sid']
        salt = keys['salt']
        method = 'session.login&md5=' + hashMe(':' + hashMe(pin) + ':' + salt)
        ret, login  = doRequest5(method)
        if ret and login['stat'] == 'ok':
            sid =  login['sid']
        else:
            print ("Fail")
    else:
        print ("Fail")

def main(method):
    sidLogin5()
    doRequest5(method)

if __name__== "__main__":
    main(sys.argv[1])

Save as filename.py edit in your pin at the beginning and run it with

python filename.py system.epg.update

Martin

This works great and I was able to also reproduce the steps with postman.
However, I am trying to run the playlist update by using the POST request I intercepted with Postman interceptor:
http://myipaddress:8866/services/service...6a9386ad56

I receive:
{
    "stat": "Failed",
    "code": 2,
    "msg": "Invalid Args."
}


If I use the same command with the session cookie it works... Any idea how would I make it work with the pin/api way, instead of imitating access through the webui?

Stefano
mvallevand
Online

Posting Freak

Ontario Canada
Posts: 45,346
Threads: 868
Joined: May 2006
#7
2022-03-16, 08:35 PM
Some API calls don't work with the PIN. Why are you doing a device scan outside the webui anyway? There is a developers sub forum for this type of question and maybe you could explain what you are trying to achieve.

Martin
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 102,403
Threads: 742
Joined: Nov 2003
#8
2022-03-16, 09:28 PM
method=setting.scan.save can't really work in isolation. It's part of a series of calls the web app makes, and by the save is called, there is lists of channels found during the scan etc.
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode