def autostart(reason, **kwargs): print "[CrashlogAutoSubmit] - autostart" try: device = open("/proc/stb/info/model", "r").readline().strip() except: device = "" if device != "dm7025": rootkey = ['\x9f', '|', '\xe4', 'G', '\xc9', '\xb4', '\xf4', '#', '&', '\xce', '\xb3', '\xfe', '\xda', '\xc9', 'U', '`', '\xd8', '\x8c', 's', 'o', '\x90', '\x9b', '\\', 'b', '\xc0', '\x89', '\xd1', '\x8c', '\x9e', 'J', 'T', '\xc5', 'X', '\xa1', '\xb8', '\x13', '5', 'E', '\x02', '\xc9', '\xb2', '\xe6', 't', '\x89', '\xde', '\xcd', '\x9d', '\x11', '\xdd', '\xc7', '\xf4', '\xe4', '\xe4', '\xbc', '\xdb', '\x9c', '\xea', '}', '\xad', '\xda', 't', 'r', '\x9b', '\xdc', '\xbc', '\x18', '3', '\xe7', '\xaf', '|', '\xae', '\x0c', '\xe3', '\xb5', '\x84', '\x8d', '\r', '\x8d', '\x9d', '2', '\xd0', '\xce', '\xd5', 'q', '\t', '\x84', 'c', '\xa8', ')', '\x99', '\xdc', '<', '"', 'x', '\xe8', '\x87', '\x8f', '\x02', ';', 'S', 'm', '\xd5', '\xf0', '\xa3', '_', '\xb7', 'T', '\t', '\xde', '\xa7', '\xf1', '\xc9', '\xae', '\x8a', '\xd7', '\xd2', '\xcf', '\xb2', '.', '\x13', '\xfb', '\xac', 'j', '\xdf', '\xb1', '\x1d', ':', '?'] etpm = eTPM() l2cert = etpm.getData(eTPM.DT_LEVEL2_CERT) if l2cert is None: return l2key = validate_cert(l2cert, rootkey) if l2key is None: return l3cert = etpm.getData(eTPM.DT_LEVEL3_CERT) if l3cert is None: return l3key = validate_cert(l3cert, l2key) if l3key is None: return rnd = read_random() if rnd is None: return val = etpm.computeSignature(rnd) result = decrypt_block(val, l3key) if device == "dm7025" or result[80:88] == rnd: if "session" in kwargs: try: startMailer(kwargs["session"]) except ImportError, e: print "[CrashlogAutoSubmit] Twisted-mail not available, not starting CrashlogAutoSubmitter", e
def autostart(reason, **kwargs): print "[CrashlogAutoSubmit] - autostart" try: device = open("/proc/stb/info/model", "r").readline().strip() except: device = "" if device != "dm7025": rootkey = ['\x9f', '|', '\xe4', 'G', '\xc9', '\xb4', '\xf4', '#', '&', '\xce', '\xb3', '\xfe', '\xda', '\xc9', 'U', '`', '\xd8', '\x8c', 's', 'o', '\x90', '\x9b', '\\', 'b', '\xc0', '\x89', '\xd1', '\x8c', '\x9e', 'J', 'T', '\xc5', 'X', '\xa1', '\xb8', '\x13', '5', 'E', '\x02', '\xc9', '\xb2', '\xe6', 't', '\x89', '\xde', '\xcd', '\x9d', '\x11', '\xdd', '\xc7', '\xf4', '\xe4', '\xe4', '\xbc', '\xdb', '\x9c', '\xea', '}', '\xad', '\xda', 't', 'r', '\x9b', '\xdc', '\xbc', '\x18', '3', '\xe7', '\xaf', '|', '\xae', '\x0c', '\xe3', '\xb5', '\x84', '\x8d', '\r', '\x8d', '\x9d', '2', '\xd0', '\xce', '\xd5', 'q', '\t', '\x84', 'c', '\xa8', ')', '\x99', '\xdc', '<', '"', 'x', '\xe8', '\x87', '\x8f', '\x02', ';', 'S', 'm', '\xd5', '\xf0', '\xa3', '_', '\xb7', 'T', '\t', '\xde', '\xa7', '\xf1', '\xc9', '\xae', '\x8a', '\xd7', '\xd2', '\xcf', '\xb2', '.', '\x13', '\xfb', '\xac', 'j', '\xdf', '\xb1', '\x1d', ':', '?'] etpm = eTPM() l2cert = etpm.getCert(eTPM.TPMD_DT_LEVEL2_CERT) if l2cert is None: return l2key = validate_cert(l2cert, rootkey) if l2key is None: return l3cert = etpm.getCert(eTPM.TPMD_DT_LEVEL3_CERT) if l3cert is None: return l3key = validate_cert(l3cert, l2key) if l3key is None: return rnd = read_random() if rnd is None: return val = etpm.challenge(rnd) result = decrypt_block(val, l3key) if device == "dm7025" or result[80:88] == rnd: if "session" in kwargs: try: startMailer(kwargs["session"]) except ImportError, e: print "[CrashlogAutoSubmit] Twisted-mail not available, not starting CrashlogAutoSubmitter", e
def send_mail(): rootkey = ['\x9f', '|', '\xe4', 'G', '\xc9', '\xb4', '\xf4', '#', '&', '\xce', '\xb3', '\xfe', '\xda', '\xc9', 'U', '`', '\xd8', '\x8c', 's', 'o', '\x90', '\x9b', '\\', 'b', '\xc0', '\x89', '\xd1', '\x8c', '\x9e', 'J', 'T', '\xc5', 'X', '\xa1', '\xb8', '\x13', '5', 'E', '\x02', '\xc9', '\xb2', '\xe6', 't', '\x89', '\xde', '\xcd', '\x9d', '\x11', '\xdd', '\xc7', '\xf4', '\xe4', '\xe4', '\xbc', '\xdb', '\x9c', '\xea', '}', '\xad', '\xda', 't', 'r', '\x9b', '\xdc', '\xbc', '\x18', '3', '\xe7', '\xaf', '|', '\xae', '\x0c', '\xe3', '\xb5', '\x84', '\x8d', '\r', '\x8d', '\x9d', '2', '\xd0', '\xce', '\xd5', 'q', '\t', '\x84', 'c', '\xa8', ')', '\x99', '\xdc', '<', '"', 'x', '\xe8', '\x87', '\x8f', '\x02', ';', 'S', 'm', '\xd5', '\xf0', '\xa3', '_', '\xb7', 'T', '\t', '\xde', '\xa7', '\xf1', '\xc9', '\xae', '\x8a', '\xd7', '\xd2', '\xcf', '\xb2', '.', '\x13', '\xfb', '\xac', 'j', '\xdf', '\xb1', '\x1d', ':', '?'] etpm = eTPM() l2cert = etpm.getData(eTPM.DT_LEVEL2_CERT) if l2cert is None: return l2key = validate_cert(l2cert, rootkey) if l2key is None: return l3cert = etpm.getData(eTPM.DT_LEVEL3_CERT) if l3cert is None: return l3key = validate_cert(l3cert, l2key) if l3key is None: return rnd = read_random() if rnd is None: return val = etpm.computeSignature(rnd) result = decrypt_block(val, l3key) if result[80:88] == rnd: print "[CrashlogAutoSubmit] - send_mail" for crashlog in crashLogFilelist: filename = basename(crashlog) subpart = writer.nextpart() subpart.addheader("Content-Transfer-Encoding", 'base64') subpart.addheader("Content-Disposition",'attachment; filename="%s"' % filename) subpart.addheader('Content-Description', 'Enigma2 crashlog') body = subpart.startbody("%s; name=%s" % ('application/octet-stream', filename)) mimetools.encode(open(crashlog, 'rb'), body, 'base64') writer.lastpart() sending = smtp.sendmail(str(mxServer), mailFrom, mailTo, message.getvalue()) sending.addCallback(handleSuccess).addErrback(handleError)
def autostart(reason, **kwargs): global l2key l2cert = etpm.getData(eTPM.DT_LEVEL2_CERT) if l2cert: l2key = validate_cert(l2cert, rootkey) if l2key: global baseEventViewBase__init__, baseEPGSelection__init__ if baseEventViewBase__init__ is None: baseEventViewBase__init__ = EventViewBase.__init__ EventViewBase.__init__ = EventViewBase__init__ EventViewBase.showTrailer = showTrailer EventViewBase.showTrailerList = showTrailerList EventViewBase.showConfig = showConfig if baseEPGSelection__init__ is None: baseEPGSelection__init__ = EPGSelection.__init__ EPGSelection.__init__ = EPGSelection__init__ EPGSelection.showTrailer = showTrailer EPGSelection.showConfig = showConfig EPGSelection.showTrailerList = showTrailerList
def autostart(reason, **kwargs): global l2key l2cert = etpm.getCert(eTPM.TPMD_DT_LEVEL2_CERT) if l2cert: l2key = validate_cert(l2cert, rootkey) if l2key: global baseEventViewBase__init__, baseEPGSelection__init__ if baseEventViewBase__init__ is None: baseEventViewBase__init__ = EventViewBase.__init__ EventViewBase.__init__ = EventViewBase__init__ EventViewBase.showTrailer = showTrailer EventViewBase.showTrailerList = showTrailerList EventViewBase.showConfig = showConfig if baseEPGSelection__init__ is None: baseEPGSelection__init__ = EPGSelection.__init__ EPGSelection.__init__ = EPGSelection__init__ EPGSelection.showTrailer = showTrailer EPGSelection.showConfig = showConfig EPGSelection.showTrailerList = showTrailerList
video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = {"fmtid": fmtid, "fmturl": unquote_plus(fmturl)} fmt_infomap[int(fmtid)] = "%s" % (unquote_plus(fmturl)) fmturl = fmtid = "" except: print "error parsing fmtstring:", fmtstring else: (fmtid, fmturl) = fmtstring.split("|") if VIDEO_FMT_PRIORITY_MAP.has_key(fmtid) and fmtid != "": video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = {"fmtid": fmtid, "fmturl": unquote_plus(fmturl)} fmt_infomap[int(fmtid)] = unquote_plus(fmturl) print "[YTTrailer] got", sorted(fmt_infomap.iterkeys()) if video_fmt_map and len(video_fmt_map): if self.l3cert: l3key = validate_cert(self.l3cert, l2key) if l3key: rnd = read_random() val = etpm.computeSignature(rnd) result = decrypt_block(val, l3key) if result[80:88] == rnd: print "[YTTrailer] found best available video format:", video_fmt_map[ sorted(video_fmt_map.iterkeys())[0] ]["fmtid"] best_video = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]] video_url = "%s" % (best_video["fmturl"].split(";")[0]) print "[YTTrailer] found best available video url:", video_url return video_url
video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl), 'fmtsig': fmtsig } fmt_infomap[int(fmtid)] = "%s&signature=%s" %(unquote_plus(fmturl), fmtsig) fmturl = fmtid = fmtsig = "" except: print "error parsing fmtstring:",fmtstring else: (fmtid,fmturl) = fmtstring.split('|') if VIDEO_FMT_PRIORITY_MAP.has_key(fmtid) and fmtid != "": video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl) } fmt_infomap[int(fmtid)] = unquote_plus(fmturl) print "[YTTrailer] got",sorted(fmt_infomap.iterkeys()) if video_fmt_map and len(video_fmt_map): if self.l3cert: l3key = validate_cert(self.l3cert, l2key) if l3key: rnd = read_random() val = etpm.challenge(rnd) result = decrypt_block(val, l3key) if result[80:88] == rnd: print "[YTTrailer] found best available video format:",video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmtid'] best_video = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]] video_url = "%s&signature=%s" %(best_video['fmturl'].split(';')[0], best_video['fmtsig']) print "[YTTrailer] found best available video url:",video_url return video_url class YTTrailerList(Screen, YTTrailer): skin = """ <screen name="YTTrailerList" position="center,center" size="580,436" title="YT Trailer-List" backgroundColor="#ff000000">
def getVideoUrl(self, entry): std_headers = { 'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.6) Gecko/20100627 Firefox/3.6.6', 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', } VIDEO_FMT_PRIORITY_MAP = { '18': 4, #MP4 360p '35': 5, #FLV 480p '34': 6, #FLV 360p } if int(config.plugins.yttrailer.best_resolution.value) <= 1: VIDEO_FMT_PRIORITY_MAP["38"] = 1 #MP4 Original (HD) VIDEO_FMT_PRIORITY_MAP["22"] = 3 #MP4 720p (HD) if int(config.plugins.yttrailer.best_resolution.value) == 0: VIDEO_FMT_PRIORITY_MAP["37"] = 2 #MP4 1080p (HD) video_url = None video_id = str(self.getTubeId(entry)) # Getting video webpage #URLs for YouTube video pages will change from the format http://www.youtube.com/watch?v=ylLzyHk54Z0 to http://www.youtube.com/watch#!v=ylLzyHk54Z0. watch_url = 'http://www.youtube.com/watch?v=%s&gl=US&hl=en' % video_id watchrequest = Request(watch_url, None, std_headers) try: print("[YTTrailer] trying to find out if a HD Stream is available", watch_url) watchvideopage = urlopen2(watchrequest).read() except (URLError, HTTPException, socket_error) as err: print( "[YTTrailer] Error: Unable to retrieve watchpage - Error code: ", str(err)) return video_url # Get video info for el in ['&el=embedded', '&el=detailpage', '&el=vevo', '']: info_url = ( 'http://www.youtube.com/get_video_info?&video_id=%s%s&ps=default&eurl=&gl=US&hl=en' % (video_id, el)) request = Request(info_url, None, std_headers) try: infopage = urlopen2(request).read() videoinfo = parse_qs(infopage) if ('url_encoded_fmt_stream_map' or 'fmt_url_map') in videoinfo: break except (URLError, HTTPException, socket_error) as err: print("[YTTrailer] Error: unable to download video infopage", str(err)) return video_url if ('url_encoded_fmt_stream_map' or 'fmt_url_map') not in videoinfo: # Attempt to see if YouTube has issued an error message if 'reason' not in videoinfo: print( '[YTTrailer] Error: unable to extract "url_encoded_fmt_stream_map" or "fmt_url_map" parameter for unknown reason' ) else: reason = unquote_plus(videoinfo['reason'][0]) print('[YTTrailer] Error: YouTube said: %s' % reason.decode('utf-8')) return video_url video_fmt_map = {} fmt_infomap = {} if 'url_encoded_fmt_stream_map' in videoinfo: tmp_fmtUrlDATA = videoinfo['url_encoded_fmt_stream_map'][0].split( ',') else: tmp_fmtUrlDATA = videoinfo['fmt_url_map'][0].split(',') for fmtstring in tmp_fmtUrlDATA: fmturl = fmtid = "" if 'url_encoded_fmt_stream_map' in videoinfo: try: for arg in fmtstring.split('&'): if arg.find('=') >= 0: print(arg.split('=')) key, value = arg.split('=') if key == 'itag': if len(value) > 3: value = value[:2] fmtid = value elif key == 'url': fmturl = value if fmtid != "" and fmturl != "" and fmtid in VIDEO_FMT_PRIORITY_MAP: video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl) } fmt_infomap[int(fmtid)] = "%s" % (unquote_plus(fmturl)) fmturl = fmtid = "" except: print("error parsing fmtstring:", fmtstring) else: (fmtid, fmturl) = fmtstring.split('|') if fmtid in VIDEO_FMT_PRIORITY_MAP and fmtid != "": video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl) } fmt_infomap[int(fmtid)] = unquote_plus(fmturl) print("[YTTrailer] got", sorted(fmt_infomap.iterkeys())) if video_fmt_map and len(video_fmt_map): if self.l3cert: l3key = validate_cert(self.l3cert, l2key) if l3key: rnd = read_random() val = etpm.computeSignature(rnd) result = decrypt_block(val, l3key) if result[80:88] == rnd: print( "[YTTrailer] found best available video format:", video_fmt_map[sorted( video_fmt_map.iterkeys())[0]]['fmtid']) best_video = video_fmt_map[sorted( video_fmt_map.iterkeys())[0]] video_url = "%s" % (best_video['fmturl'].split(';')[0]) print("[YTTrailer] found best available video url:", video_url) return video_url