Kodi Community Forum
tunlr - dns service for accessing geo locked video content - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: tunlr - dns service for accessing geo locked video content (/showthread.php?tid=157430)



tunlr - dns service for accessing geo locked video content - rogerthis - 2013-02-24

http://tunlr.net/ Tunlr is a free dns proxy, for getting videos in geo locked sites in the UK and US.

http://tunlr.net/faq/supported-services-players/ - supported players

Here is the code to use tunlr in an addon, I have used bbc iplayer as an example:
Original code here https://github.com/oe-alliance/oe-alliance-plugins/blob/master/OnDemand/src/bbciplayer.py

You need import dnspython http://www.dnspython.org/
Code:
from dns.resolver import Resolver

Code:
if html1.find('notukerror') > 0:
            self.notUK = 1
            print "Non UK Address"
            opener = urllib2.build_opener(MyHTTPHandler)
            old_opener = urllib2._opener
            urllib2.install_opener (opener)
            url2 = 'http://www.bbc.co.uk/mediaselector/4/mtis/stream/'+links
            #print 'url2',url2
            req = urllib2.Request(url2)
            req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3 Gecko/2008092417 Firefox/3.0.3')
            response = urllib2.urlopen(req)
            html1 = str(response.read())
            response.close()
            urllib2.install_opener (old_opener)

Code:
class MyHTTPConnection(httplib.HTTPConnection):
    def connect (self):
        resolver = Resolver()
        resolver.nameservers = ['142.54.177.158']  #tunlr dns address
        answer = resolver.query(self.host,'A')
        self.host = answer.rrset.items[0].address
        self.sock = socket.create_connection ((self.host, self.port))

class MyHTTPHandler(urllib2.HTTPHandler):
    def http_open(self, req):
        return self.do_open (MyHTTPConnection, req)

What this code does is, when it is detected that you have an outside UK IP, it uses tunlr as your dns server. Then it turns it off again once the play url is found. And it will play using your own dns. So it not wasting tunlr dns unless it needs to.


RE: tunlr - dns service for accessing geo locked video content - akiaki - 2013-02-26

This is great, can you make this into an addon?
Is this code meant to go into the iplayer addon directly somewhere?


RE: tunlr - dns service for accessing geo locked video content - perro6969 - 2013-02-27

More than great! Have someone tried it on the Vevo addon?


RE: tunlr - dns service for accessing geo locked video content - moneymaker - 2013-03-02

This could be even code in to hulu


RE: tunlr - dns service for accessing geo locked video content - ShinobiX9X - 2013-12-09

Could i get a howto to do this for this and hulu and others?

Thanks in advance


RE: tunlr - dns service for accessing geo locked video content - deadbuzzard - 2013-12-17

Where do I need to add the code posted here to?


RE: tunlr - dns service for accessing geo locked video content - RedPenguin - 2013-12-30

Do you think you could work this "code" into your tunlr script and enable us to watch live BBC streams in XBMC's iPlayer addon?

https://tunlr.net/forums/topic/how-to-bbc-live-streams-using-tunlr/

This method works perfectly with Firefox and using Tunlr as DNS.

According to this thread http://forum.xbmc.org/showthread.php?tid=77500 it's already possible to modify an outgoing HTTP Header so I would assume this shouldn't be insanely difficult.