Page 1 of 1

API and Database results differ

Posted: Thu Jan 28, 2016 11:13 am
by misiming
Hello all:

I'm attempting to write a plugin for Plex Media Server and I'm discovering channels flagged as visible either true or false in database are not reflecting the same results in the API.

Example:

From Database:

select chanid,channum,visible from channel where channum = '31';
+--------+---------+---------+
| chanid | channum | visible |
+--------+---------+---------+
| 1031 | 31 | 0 |
| 10638 | 31 | 1 |
+--------+---------+---------+
2 rows in set (0.00 sec)


From API
/ChannelInfoList/ChannelInfos/ChannelInfo
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanId=1031
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanNum=31
/ChannelInfoList/ChannelInfos/ChannelInfo/Visible=false

/ChannelInfoList/ChannelInfos/ChannelInfo/ChanId=10638
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanNum=31
/ChannelInfoList/ChannelInfos/ChannelInfo/Visible=false


Are the APIs not pulling from the channel table? How do I fix?

Thanks

Re: API and Database results differ

Posted: Thu Jan 28, 2016 3:27 pm
by bill6502
Hi,
If you're using: backend:6544/Channel/GetChannelInfo?ChanId=10638,
then it "works for me" in 0.28-pre. I tested with a channel that had two
DB entries with the same ChanNum, like yours above.

Please add mythbackend --version (just the line similar to: v0.28-pre-3498-ge5b211f.)
Including the actual queries you used would be good. And repeating this for both channels so we
can see the raw data would help:

Code: Select all

curl http://yourBackend:6544/Channel/GetChannelInfo?ChanId=forBothYourChannels|sed "s/></>\n</g"|egrep "<ChanId>|<ChanNum>|<Visible>"

Re: API and Database results differ

Posted: Thu Jan 28, 2016 4:23 pm
by misiming
My Version is MythTV Version : v0.27.5-72-g5e18f50


curl -vs "http://10.250.40.25:6544/Channel/GetCha ... tails=true" 2>/dev/null | xml2 | grep "ChanId=\|ChanNum=\|Visible=" | grep -B1 -A1 "ChanNum=31$"

/ChannelInfoList/ChannelInfos/ChannelInfo/ChanId=10638
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanNum=31
/ChannelInfoList/ChannelInfos/ChannelInfo/Visible=false
--
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanId=1031
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanNum=31
/ChannelInfoList/ChannelInfos/ChannelInfo/Visible=false

curl -vs "http://10.250.40.25:6544/Channel/GetCha ... anID=10638" 2>/dev/null | xml2 | grep "ChanId=\|ChanNum=\|Visible="

/ChannelInfo/ChanId=10638
/ChannelInfo/ChanNum=31
/ChannelInfo/Visible=false

curl -vs "http://10.250.40.25:6544/Channel/GetCha ... hanID=1031" 2>/dev/null | xml2 | grep "ChanId=\|ChanNum=\|Visible="

/ChannelInfo/ChanId=1031
/ChannelInfo/ChanNum=31
/ChannelInfo/Visible=false



An interesting thing of note is when I have 2 channels with the same Channel Number. 1 is visible and the other is not. First one wins.

UPDATE channel SET visible = 0 WHERE chanid = '10638';
UPDATE channel SET visible = 1 WHERE chanid = '1031';
SELECT chanid,channum,visible FROM channel WHERE channum = '31';
+--------+---------+---------+
| chanid | channum | visible |
+--------+---------+---------+
| 1031 | 31 | 1 |
| 10638 | 31 | 0 |
+--------+---------+---------+

curl -vs "http://10.250.40.25:6544/Channel/GetCha ... tails=true" 2>/dev/null | xml2 | grep "ChanId=\|ChanNum=\|Visible=" | grep -B1 -A1 "ChanNum=31$"
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanId=10638
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanNum=31
/ChannelInfoList/ChannelInfos/ChannelInfo/Visible=true
--
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanId=1031
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanNum=31
/ChannelInfoList/ChannelInfos/ChannelInfo/Visible=true

curl -vs "http://10.250.40.25:6544/Channel/GetCha ... hanID=1031" 2>/dev/null | xml2 | grep "ChanId=\|ChanNum=\|Visible="/ChannelInfo/ChanId=1031
/ChannelInfo/ChanNum=31
/ChannelInfo/Visible=true

curl -vs "http://10.250.40.25:6544/Channel/GetCha ... anID=10638" 2>/dev/null | xml2 | grep "ChanId=\|ChanNum=\|Visible="/ChannelInfo/ChanId=10638
/ChannelInfo/ChanNum=31
/ChannelInfo/Visible=true


I tried deleting all non-visible channels DELETE from channel WHERE visible = 0 ; That fixed it until something appears to re-add all the channels I deleted.

Re: API and Database results differ

Posted: Mon Feb 15, 2016 9:21 pm
by PhilB
You mention Visible 0 or 1.
Shouldn't that be false or true?
Phil

Re: API and Database results differ

Posted: Wed Feb 17, 2016 4:57 am
by bill6502
Can't duplicate this in 0.28-pre. Tried with all 4 combinations of
visible in the DB.

Code: Select all

$ curl --silent http://mc0:6544/Channel/GetChannelInfoList?Details=true | xml2 | egrep "ChanId=1021|ChanId=2602|ChanNum=2_1|Visible="
...
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanId=1021
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanNum=2_1
/ChannelInfoList/ChannelInfos/ChannelInfo/IconURL=/Guide/GetChannelIcon?ChanId=1021
/ChannelInfoList/ChannelInfos/ChannelInfo/Visible=false
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanId=2602
/ChannelInfoList/ChannelInfos/ChannelInfo/ChanNum=2_1
/ChannelInfoList/ChannelInfos/ChannelInfo/IconURL=/Guide/GetChannelIcon?ChanId=2602
/ChannelInfoList/ChannelInfos/ChannelInfo/Visible=true
...

Re: API and Database results differ

Posted: Wed Feb 17, 2016 7:01 pm
by PhilB
In 0.27 this:

Code: Select all

curl http://192.168.2.99:6544/Channel/GetChannelInfoList?StartIndex=1\&SourceID=1 | sed "s/></>\n</g" | grep Visible
 
Gives a load of true and false lines:

<Visible>false</Visible>
<Visible>true</Visible>
<Visible>true</Visible>
<Visible>false</Visible>
<Visible>true</Visible>

Has your database got corrupted by your SQL stuff with Visible set to 0 or 1 rather than false or true?

Phil