2010-01-17, 13:41
Hi,
I am writing a simple plugin that goes to a site shows all the channels in a list, when you click on a channel it shows the stream link, you click on that and the video plays.
My issue is if I do the above once it works perfectly but when I stop the video and go back one level up, or don't play the video and go one level up to the main list, if I click on a channel or even the same channel as last time, I do not get the same behavior. Now if I click one more time, it behaves like the first time.
Looking at the traffic and headers I see the referer changing that I am not sure if XBMC changes, is there way to handle this using the directory UP, i.e. ".." option in the list.
Here is the error I get:
The plugin does support cookies as well as referer control. Here is the code that does that:
Below are the headers I see, based on responses from FF:
[HTML]GET http://www.livedesi.tv/category/6/All-Channels.html HTTP/1.1
Host: www.livedesi.tv
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.livedesi.tv/
Cookie: PHPSESSID=fff06aba6b40183f56d748383f18271b
HTTP/1.1 200 OK
Date: Sun, 17 Jan 2010 10:53:57 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
Content-Length: 36522
------------------------------------------------------------------
GET http://www.livedesi.tv/live/93/Zee-Cinema.html HTTP/1.1
Host: www.livedesi.tv
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.livedesi.tv/category/6/All-Channels.html
Cookie: PHPSESSID=fff06aba6b40183f56d748383f18271b
HTTP/1.1 200 OK
Date: Sun, 17 Jan 2010 10:54:16 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
Content-Length: 10285
------------------------------------------------------------------
GET http://www.livedesi.tv/category/6/All-Channels.html HTTP/1.1
Host: www.livedesi.tv
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.livedesi.tv/
Cookie: PHPSESSID=fff06aba6b40183f56d748383f18271b
HTTP/1.1 200 OK
Date: Sun, 17 Jan 2010 10:54:26 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
Content-Length: 38035
------------------------------------------------------------------
GET http://www.livedesi.tv/live/97/Geo-News.html HTTP/1.1
Host: www.livedesi.tv
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.livedesi.tv/category/6/All-Channels.html
Cookie: PHPSESSID=fff06aba6b40183f56d748383f18271b
HTTP/1.1 200 OK
Date: Sun, 17 Jan 2010 10:54:56 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
Content-Length: 15569
------------------------------------------------------------------
[/HTML]
I would appreciate your expert help very much.
I am writing a simple plugin that goes to a site shows all the channels in a list, when you click on a channel it shows the stream link, you click on that and the video plays.
My issue is if I do the above once it works perfectly but when I stop the video and go back one level up, or don't play the video and go one level up to the main list, if I click on a channel or even the same channel as last time, I do not get the same behavior. Now if I click one more time, it behaves like the first time.
Looking at the traffic and headers I see the referer changing that I am not sure if XBMC changes, is there way to handle this using the directory UP, i.e. ".." option in the list.
Here is the error I get:
Code:
03:37:57 T:2948 M:257441792 NOTICE: -->Python Interpreter Initialized<--
03:37:58 T:2948 M:254816256 NOTICE: Supplied Top-->
03:37:58 T:2948 M:254816256 NOTICE: http://www.livedesi.tv/live/94/Zee-Punjabi.html
03:37:59 T:624 M:254713856 ERROR: DIRECTORY::CDirectory::GetDirectory - Error getting plugin://video/LiveDesi.tv/?http://www.livedesi.tv/live/94/Zee-Punjabi.html
03:37:59 T:624 M:254713856 ERROR: CGUIMediaWindow::GetDirectory(plugin://video/LiveDesi.tv/?http://www.livedesi.tv/live/94/Zee-Punjabi.html) failed
The plugin does support cookies as well as referer control. Here is the code that does that:
Code:
urlopen = urllib2.urlopen
Request = urllib2.Request
cj = cookielib.LWPCookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
...
...
...
req = urllib2.Request(url)
req.add_header('User-Agent', USER_AGENT)
req.add_header('Referer', REFERER)
response = urlopen(req)
link=response.read()
response.close()
Below are the headers I see, based on responses from FF:
[HTML]GET http://www.livedesi.tv/category/6/All-Channels.html HTTP/1.1
Host: www.livedesi.tv
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.livedesi.tv/
Cookie: PHPSESSID=fff06aba6b40183f56d748383f18271b
HTTP/1.1 200 OK
Date: Sun, 17 Jan 2010 10:53:57 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
Content-Length: 36522
------------------------------------------------------------------
GET http://www.livedesi.tv/live/93/Zee-Cinema.html HTTP/1.1
Host: www.livedesi.tv
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.livedesi.tv/category/6/All-Channels.html
Cookie: PHPSESSID=fff06aba6b40183f56d748383f18271b
HTTP/1.1 200 OK
Date: Sun, 17 Jan 2010 10:54:16 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
Content-Length: 10285
------------------------------------------------------------------
GET http://www.livedesi.tv/category/6/All-Channels.html HTTP/1.1
Host: www.livedesi.tv
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.livedesi.tv/
Cookie: PHPSESSID=fff06aba6b40183f56d748383f18271b
HTTP/1.1 200 OK
Date: Sun, 17 Jan 2010 10:54:26 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
Content-Length: 38035
------------------------------------------------------------------
GET http://www.livedesi.tv/live/97/Geo-News.html HTTP/1.1
Host: www.livedesi.tv
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.livedesi.tv/category/6/All-Channels.html
Cookie: PHPSESSID=fff06aba6b40183f56d748383f18271b
HTTP/1.1 200 OK
Date: Sun, 17 Jan 2010 10:54:56 GMT
Server: Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8i DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
X-Powered-By: PHP/5.2.8
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
Content-Length: 15569
------------------------------------------------------------------
[/HTML]
I would appreciate your expert help very much.