VideoHelp Forum




+ Reply to Thread
Results 1 to 6 of 6
  1. Hello,

    I need a curl command to extract m3u8 URL from below website:

    https://www.atv.com.tr/canli-yayin

    The resulting URL will be something like this:

    https://trkvz.daioncdn.net/atv/atv_720p.m3u8?e=1682287651&st=r6LEl3pdxdnOTroaZv7YwA&si...c185a314e&ce=3

    Please note that the parameters "e", "st" and "sid" will change on each page reload.

    Thanks in advance.
    Last edited by tonygables; 24th Apr 2023 at 05:01.
    Quote Quote  
  2. you take a python script too?

    not a beautiful script, but working/ (do it in few seconds so for the fast i think its enough) script.

    so i can test it only with 480p because my browser dont show me more.


    you need to install python3

    selenium
    pip3

    pip3 installs for the import

    and google chrome stable version

    Code:
    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    import os
    import requests
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.support.ui import Select
    import time
    import undetected_chromedriver as uc
    from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.common.by import By
    import json
    import re
    
    
    options = uc.ChromeOptions()
    options.add_argument("--enable-logging=performance")
    options.add_argument("--enable-javascript")
    options.add_argument('--headless=new')
    options.add_argument("--no-sandbox")
    
    
    desired_capabilities = DesiredCapabilities.CHROME.copy()
    logging_prefs = {'performance': 'ALL'}
    desired_capabilities['goog:loggingPrefs'] = logging_prefs
    
    browser = uc.Chrome(options=options, desired_capabilities=desired_capabilities)
    
    browser.get("https://www.atv.com.tr/canli-yayin")
    time.sleep(10)
    
    m3u8_url_pattern = re.compile(r'https://trkvz.daioncdn.net/atv/atv_480p.m3u8*')
    
    logs = browser.get_log('performance')
    
    m3u8_url = None
    
    for log in logs:
        try:
    
            message = json.loads(log['message'])
    
    
            if 'message' in message and m3u8_url_pattern.match(message['message']['params']['request']['url']):
                # URL aus Eintrag extrahieren und in Variable speichern
                url = message['message']['params']['request']['url']
                if m3u8_url is None and url.startswith('https://trkvz.daioncdn.net'):
                    m3u8_url = url
                    print(m3u8_url)
    
        except:
            pass

    Image
    [Attachment 70495 - Click to enlarge]
    Quote Quote  
  3. Code:
    import requests
    import re
    
    headers = {
        'Origin': 'https://www.atv.com.tr',
        'Referer': 'https://www.atv.com.tr/',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
    }
    
    resp1 = requests.get('https://securevideotoken.tmgrup.com.tr/webtv/secure?000000&url=https%3A%2F%2Ftrkvz.daioncdn.net%2Fatv%2Fatv.m3u8%3Fce%3D3%26app%3Dd1ce2d40-5256-4550-b02e-e73c185a314e', headers=headers).json()
    
    m3u8_url = resp1['Url']
    print(f'\n{m3u8_url}\n')
    
    import requests
    
    headers = {
        'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
    }
    
    resp2 = requests.get(m3u8_url, headers=headers).text
    
    atv_list = re.findall(r'#EXT-X-STREAM-INF:.*\n(.*\.m3u8.*)', resp2)
    
    for m3u8_res in atv_list:
        print(f'https://trkvz.daioncdn.net/atv/{m3u8_res}')
    Image
    [Attachment 70515 - Click to enlarge]



    curl, but python is better for this purpose..

    Code:
    curl "https://securevideotoken.tmgrup.com.tr/webtv/secure?000000&url=https%3A%2F%2Ftrkvz.daioncdn.net%2Fatv%2Fatv.m3u8%3Fce%3D3%26app%3Dd1ce2d40-5256-4550-b02e-e73c185a314e"   -H "Origin: https://www.atv.com.tr"   -H "Referer: https://www.atv.com.tr/"   -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
    Last edited by sk8ordi3; 25th Apr 2023 at 01:56. Reason: curl ' to "
    Quote Quote  
  4. Thank you guys both. Fantastic job.

    @sk8ordi3

    From where did you get the below URL. I don't see it in the network tab.

    https://securevideotoken.tmgrup.com.tr/webtv/secure?000000&url=https%3A%2F%2Ftrkvz.dai...e-e73c185a314e
    Quote Quote  
  5. Originally Posted by tonygables View Post
    Thank you guys both. Fantastic job.

    @sk8ordi3

    From where did you get the below URL. I don't see it in the network tab.
    you can "find it" here in dev menu
    just figured out the numbers is "fake" so the zero's working..

    Image
    [Attachment 70522 - Click to enlarge]
    Quote Quote  
  6. who would be interested this is for vod contents:

    Code:
    import requests
    import re
    
    print('\ntest link: https://www.atv.com.tr/kurulus-osman/121-bolum/izle\ntest link: https://www.atv.com.tr/akinci-cizgi-dizi/9-bolum/izle\n')
    link = input('link: ')
    
    headers = {
        'authority': 'www.atv.com.tr',
        'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36',
    }
    
    resp1 = requests.get(link, headers=headers).text
    
    video_id = re.findall(r'contentUrl\":\"(.*)_', resp1)[0].strip()
    
    headers = {
        'Origin': 'https://www.atv.com.tr',
        'Referer': 'https://www.atv.com.tr/',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36',
    }
    
    resp2 = requests.get('https://securevideotoken.tmgrup.com.tr/webtv/secure?000000&url='+video_id+'.hb.smil%2Fplaylist.m3u8', headers=headers).json()
    
    m3u8_url = resp2['Url']
    print(f'\n{m3u8_url}\n')
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!