Esempio n. 1
0
    def _request(self, cmd, params, inauth=None):

        if self.AUTH_OK == False:
            if inauth == None:
                self._auth(self.login, self.password)

        url = IPTV_API % cmd
        if inauth:
            postparams = params
        else:
            url = url + "?" + params
            postparams = None

            # log.info('Requesting %s' % url)
        xbmc.log("[Kartina.TV] REQUESTING: %s" % url)

        ua = self.genUa()

        req = urllib2.Request(
            url,
            postparams,
            {
                "User-agent": ua,
                "Connection": "Close",
                "Accept": "application/json, text/javascript, */*",
                "X-Requested-With": "XMLHttpRequest",
            },
        )

        if inauth == None and getattr(xbmc, "nonXBMC", None) is not None:
            from ga import track_page_view
            from ga import get_visitor_id

            path = cmd + "?" + params
            extra = {}
            extra["screen"] = xbmc.getInfoLabel("System.ScreenMode")
            track_page_view(get_visitor_id(self.login, None), path, ua, extra)

        if COOKIEJAR == None and (self.SID != None):
            req.add_header("Cookie", self.SID_NAME + "=" + self.SID + ";")

        rez = urllib2.urlopen(req).read()

        xbmc.log("[Kartina.TV] Got %s" % rez, level=xbmc.LOGDEBUG)

        try:
            res = JSONDECODE(rez)
        except:
            xbmc.log("[Kartina.TV] Error.. :(")

            # xbmc.log('[Kartina.TV] Got JSON: %s' % res)

        self._errors_check(res)

        if COOKIEJAR != None:
            xbmc.log("[Kartina.TV] Saving cookies: %s" % COOKIEFILE)
            COOKIEJAR.save(COOKIEFILE)

        return res
Esempio n. 2
0
	def _request(self, cmd, params, inauth = None):
		
		if self.AUTH_OK == False:
			if inauth == None:
				self._auth(self.login, self.password)
		
		url = IPTV_API % cmd
		if inauth:
			postparams = params
		else:
			url = url + '?' + params
			postparams = None
		
		#log.info('Requesting %s' % url)
		xbmc.log('[Kartina.TV] REQUESTING: %s' % url)
		
		ua = self.genUa()
		
		req = urllib2.Request(url, postparams, {'User-agent': ua, 'Connection': 'Close', 'Accept': 'application/json, text/javascript, */*', 'X-Requested-With': 'XMLHttpRequest'})
		
		if inauth == None and getattr(xbmc, "nonXBMC", None) is not None:
			from ga import track_page_view
			from ga import get_visitor_id
			path = cmd+"?"+params
			extra = {}
			extra['screen'] = xbmc.getInfoLabel('System.ScreenMode')
			track_page_view(get_visitor_id(self.login, None), path, ua, extra)
		
		if COOKIEJAR == None and (self.SID != None):
			req.add_header("Cookie", self.SID_NAME + "=" + self.SID + ";")
		
		rez = urllib2.urlopen(req).read()
		
		xbmc.log('[Kartina.TV] Got %s' % rez, level=xbmc.LOGDEBUG)
		
		try:
			res = JSONDECODE(rez)
		except:
			xbmc.log('[Kartina.TV] Error.. :(')
		
		#xbmc.log('[Kartina.TV] Got JSON: %s' % res)
			
		self._errors_check(res)
		
		if COOKIEJAR != None:
			xbmc.log('[Kartina.TV] Saving cookies: %s' % COOKIEFILE)
			COOKIEJAR.save(COOKIEFILE)
		
		return res
def gserve(environ, start_response):    
    try:
        response = track_page_view(environ)
    except Exception, e:
        print e
        start_response("503 Service Unavailable", [])
        return ["<h1>Exception loading GA code</h1><p>%s</p>" % str(e)]
Esempio n. 4
0
def gserve(environ, start_response):
    try:
        response = track_page_view(environ)
    except Exception, e:
        print e
        start_response("503 Service Unavailable", [])
        return ["<h1>Exception loading GA code</h1><p>%s</p>" % str(e)]
Esempio n. 5
0
    def track(self, trackingId, debug):

        # Perform remote HTTP request to update GA stats
        url = ga.track_page_view(self.request, self.request.response, self.request.environ, trackingId, debug=debug, synchronous=False)

        # return '<!-- GA --> <img alt="" src="%s" />' % url # Tracker marker, does really nothing

        if url:
            return '<img class="google-analytics" alt="" src="%s" />' % url # Tracker marker, does really nothing
        else:
            return '<img class="google-analytics google-analytics-broken" alt="" src="" />'
Esempio n. 6
0
    from ga import track_page_view
    what = mode
    if title:
        frmt = '[LIVE] %s/'
        if 'ts' in params:
            frmt = '[ARCH] %s/'
        if 'vod' in params:
            frmt = '[VOD] %s/'
        what = frmt % title
    if what == None:
        what = 'Root'
    urlpath = what + sys.argv[2]
    extras = {}
    extras['screen'] = xbmc.getInfoLabel('System.ScreenMode')
    try:
        track_page_view(__settings__.getSetting('ga_uid'), urlpath,
                        PLUGIN_CORE.genUa(), extras)
    except:
        xbmc.log('[%s] problems tracking GA' % PLUGIN_NAME)

    if mode == 'WatchTV':
        WatchTV(PLUGIN_CORE, channel, params)

    elif mode == 'Archive':
        Archive(PLUGIN_CORE, channel, params)

    elif mode == 'VideoLib':
        VideoLib(PLUGIN_CORE, params)

    elif mode == 'Video':
        Video(PLUGIN_CORE, params)
 def run(self, environ, start_response):
     response = track_page_view(environ)
     start_response(response['response_code'], response['response_headers'])
     ret = response.get('response_body')
     return [ret]
Esempio n. 8
0
	
	what = mode
	if title:
		frmt = '[LIVE] %s/'
		if 'ts' in params:
			frmt = '[ARCH] %s/'
		if 'vod' in params:
			frmt = '[VOD] %s/'
		what = frmt % title
	if what == None:
		what = 'Root'
	urlpath = what + sys.argv[2]
	extras = {}
	extras['screen'] = xbmc.getInfoLabel('System.ScreenMode')
	try:
		track_page_view(__settings__.getSetting('ga_uid'), urlpath, PLUGIN_CORE.genUa(), extras) 
	except:
		xbmc.log('[%s] problems tracking GA' % PLUGIN_NAME)

	
	if mode == 'WatchTV':
		WatchTV(PLUGIN_CORE, channel, title, params)
	
	elif mode == 'Archive':
		Archive(PLUGIN_CORE, channel, params)
	
	elif mode == 'PlayNext':
		PlayNext(PLUGIN_CORE, channel)
	
	elif mode == 'ShowNowNextHint':
		ShowNowNextHint(PLUGIN_CORE, channel)