Skip to content

Instantly share code, notes, and snippets.

@probonopd
Last active December 19, 2015 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save probonopd/5878065 to your computer and use it in GitHub Desktop.
Save probonopd/5878065 to your computer and use it in GitHub Desktop.
To be done: Rewrite parser for Xoro HRS 8530 station lists in Python; translate common.java by Matthias Müller (dvb.matt)
http://mobile.rtv.de/
# if the image src contains zdf, then change the link of the parent
$('img[src*="ard"]').parent().attr('href','javascript:zap(1)');
$('img[src*="zdf"]').parent().attr('href','javascript:zap(2)');
$('img[src*="rtl"]').parent().attr('href','javascript:zap(3)');
http://mobile.rtv.de/
# if the image src contains zdf, then change the link of the parent
$('img[src*="ard"]').parent().attr('href','javascript:Android.sendPronto("0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0622 015B 0057 0016 0E6C ; 0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0622 015B 0057 0016 0E6C")');
$('img[src*="zdf"]').parent().attr('href','javascript:Android.sendPronto("0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0622 015B 0057 0016 0E6C ; 0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0622 015B 0057 0016 0E6C")');
$('img[src*="rtl"]').parent().attr('href','javascript:Android.sendPronto("0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0622 015B 0057 0016 0E6C ; 0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0016 0016 0041 0016 0622 015B 0057 0016 0E6C ; 0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0622 015B 0057 0016 0E6C ; 0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0622 015B 0057 0016 0E6C")');
Use http://benalman.com/code/test/jquery-run-code-bookmarklet/ to convert into a full bookmarklet
# To be investigated how this can be made shorter.
# Maybe the best would be just to send the station names to Android and do the lookup of the IR codes there.
# Bookmarklet to inject JavaScript into a foreign page
javascript:(function(){var%20s=document.createElement('script');s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js');document.getElementsByTagName('body')[0].appendChild(s);alert('Script%20injected!');})();
(function(){
// the minimum version of jQuery we want
var v = "1.3.2";
// check prior inclusion and version
if (window.jQuery === undefined || window.jQuery.fn.jquery < v) {
var done = false;
var script = document.createElement("script");
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + v + "/jquery.min.js";
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
done = true;
initMyBookmarklet();
}
};
document.getElementsByTagName("head")[0].appendChild(script);
} else {
initMyBookmarklet();
}
function initMyBookmarklet() {
(window.myBookmarklet = function() {
// your JavaScript code goes here!
$('img[src*="ard"]').parent().attr('href','javascript:Android.sendPronto("0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0622 015B 0057 0016 0E6C ; 0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0622 015B 0057 0016 0E6C")');
$('img[src*="zdf"]').parent().attr('href','javascript:Android.sendPronto("0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0622 015B 0057 0016 0E6C ; 0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0622 015B 0057 0016 0E6C")');
$('img[src*="rtl"]').parent().attr('href','javascript:Android.sendPronto("0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0622 015B 0057 0016 0E6C ; 0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0016 0016 0041 0016 0622 015B 0057 0016 0E6C ; 0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0622 015B 0057 0016 0E6C ; 0000 006C 0022 0002 015B 00AD 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0041 0016 0041 0016 0016 0016 0016 0016 0016 0016 0041 0016 0016 0016 0041 0016 0016 0016 0016 0016 0041 0016 0041 0016 0041 0016 0622 015B 0057 0016 0E6C")')
alert("Injected!");
})();
}
})();
alert("Injected!");
function zap(arguments) {
for (var i = 0; i < arguments.length; ++i)
alert(arguments[i]);
}
#/usr/bin/env python
#
# Read station lists of Xoro HRS 8530 (Mstar chipset)
# Test with http://data.xoro.de/Firmware/HRS8530v2/Senderliste/HB_DATABASE_6_29.DBM
#
import os, sys, glob
class StationFile:
def __init__(self, filename):
self.filename = filename
def __repr__(self):
return("<StationFile '%s'>" % (self.filename))
class Station(object):
def __init__(self, sf, offset):
self.sf = sf
self.offset = offset
self.f = open(self.sf.filename, "r")
self.idx = 256 * ord(self.get_section(65, 1)) + ord(self.get_section(64, 1))
self.number = self.idx + 1
self.name = self.get_section(0, 64).replace("\x00","").strip()
self.name = "".join(i for i in self.name if ((ord(i)<128) and (ord(i)>31))) # Strip non-ASCII characters; fixme
self.num_type = ord(self.get_section(80, 1))
self.type = "Unknown"
if(self.num_type == 1): self.type = "TV"
elif(self.num_type == 2): self.type = "Radio"
else: self.type = self.num_type
self.sid = 256 * ord(self.get_section(105, 1)) + ord(self.get_section(104, 1))
search = os.path.dirname(os.path.abspath(__file__)) + "/static/logos/*%x.png" % (self.sid)
results = glob.glob(search)
if(len(results) >0):
self.logo = results[0].replace(os.path.dirname(os.path.abspath(__file__)),"")
else:
self.logo = None
def get_section(self, start, length):
self.f.seek(self.offset + start)
a = self.f.read(length)
return a
def __repr__(self):
return ("<%s #%i (Service ID %s = 0x%x) '%s' at file offset 0x%x>" % (self.type, self.number, self.sid, self.sid, self.name, self.offset))
if(__name__ == "__main__"):
print("Running tests...")
filepath = os.path.dirname(os.path.abspath(__file__)) + "/HB_DATABASE.DBM"
if not (os.path.isfile(filepath)):
import urllib
print "Downloading %s..." % (filepath)
urllib.urlretrieve ("http://data.xoro.de/Firmware/HRS8530v2/Senderliste/HB_DATABASE_6_29.DBM", filepath)
f = StationFile(filepath)
print f
for type in ["TV"]:
print(type)
i = 0
while(i<580): # FIXME: Remove hardcoding
s = Station(f,125734+i*164)
if ((s.type == type) and (s.logo)):
print s
print s.logo
i = i + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment