Changeset 45114


Ignore:
Timestamp:
01/10/21 00:42:25 (10 months ago)
Author:
obi
Message:

fix typo

Location:
titan/mediathek/localhoster
Files:
2 edited

Legend:

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

    r45111 r45114  
    176176    return source_list
    177177
    178 
    179 def get_media_url(url, result_blacklist=None, patterns=None, generic_patterns=True):
    180     if patterns is None: patterns = []
    181     scheme = urlparse(url).scheme
     178def get_media_url(url, result_blacklist=None, patterns=None, generic_patterns=True, referer=True):
     179    if patterns is None:
     180        patterns = []
     181    scheme = urllib_parse.urlparse(url).scheme
    182182    if result_blacklist is None:
    183183        result_blacklist = []
     
    188188    net = common.Net()
    189189    headers = {'User-Agent': common.RAND_UA}
    190 
     190    if referer:
     191        headers.update({'Referer': url})
    191192    response = net.http_GET(url, headers=headers)
    192193    response_headers = response.get_headers(as_dict=True)
    193     headers.update({'Referer': url})
    194194    cookie = response_headers.get('Set-Cookie', None)
    195195    if cookie:
    196196        headers.update({'Cookie': cookie})
    197197    html = response.content
    198 
     198    if not referer:
     199        headers.update({'Referer': url})
    199200    source_list = scrape_sources(html, result_blacklist, scheme, patterns, generic_patterns)
    200201    source = pick_source(source_list)
     
    285286    response = urllib_request.urlopen(request)
    286287    return response.geturl()
     288   
     289def _default_get_url(self, host, media_id, template=None):
     290    if template is None:
     291        template = 'http://{host}/embed-{media_id}.html'
     292    host = self._get_host(host)
     293    return template.format(host=host, media_id=media_id)
  • titan/mediathek/localhoster/upstream.py

    r45112 r45114  
    4848
    4949    def get_media_url(self, host, media_id):
    50         referer = False
    5150        print helpers.get_media_url(self.get_url(host, media_id),
    5251                                    patterns=[r'''sources:\s*\[(?:{file:)?\s*"(?P<url>[^"]+)'''],
Note: See TracChangeset for help on using the changeset viewer.