Ignore:
Timestamp:
01/10/21 00:03:05 (3 years ago)
Author:
obi
Message:

tithek add streamtape

Location:
titan/mediathek/localhoster/lib
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • titan/mediathek/localhoster/lib/helpers.py

    r41178 r45111  
    2121import jsunpack
    2222from urlparse import urlparse
     23import six
     24from six.moves import urllib_parse, urllib_request
    2325#from urlresolver import common
    2426#from urlresolver.resolver import ResolverError
     
    237239    return results
    238240
     241def fun_decode(vu, lc, hr='16'):
     242    import time
     243
     244    def calcseed(lc, hr):
     245        f = lc.replace('$', '').replace('0', '1')
     246        j = int(len(f) / 2)
     247        k = int(f[0:j + 1])
     248        el = int(f[j:])
     249        fi = abs(el - k) * 4
     250        s = str(fi)
     251        i = int(int(hr) / 2) + 2
     252        m = ''
     253        for g2 in range(j + 1):
     254            for h in range(1, 5):
     255                n = int(lc[g2 + h]) + int(s[g2])
     256                if n >= i:
     257                    n -= i
     258                m += str(n)
     259        return m
     260
     261    if vu.startswith('function/'):
     262        vup = vu.split('/')
     263        uhash = vup[7][0: 2 * int(hr)]
     264        nchash = vup[7][2 * int(hr):]
     265        seed = calcseed(lc, hr)
     266        if seed and uhash:
     267            for k in range(len(uhash) - 1, -1, -1):
     268                el = k
     269                for m in range(k, len(seed)):
     270                    el += int(seed[m])
     271                while el >= len(uhash):
     272                    el -= len(uhash)
     273                n = ''
     274                for o in range(len(uhash)):
     275                    n += uhash[el] if o == k else uhash[k] if o == el else uhash[o]
     276                uhash = n
     277            vup[7] = uhash + nchash
     278        vu = '/'.join(vup[2:]) + '&rnd={}'.format(int(time.time() * 1000))
     279    return vu
     280
     281
     282def get_redirect_url(url, headers={}):
     283    request = urllib_request.Request(url, headers=headers)
     284    request.get_method = lambda: 'HEAD'
     285    response = urllib_request.urlopen(request)
     286    return response.geturl()
Note: See TracChangeset for help on using the changeset viewer.