Skip to content

Dailymotion #1310

@manolischania

Description

@manolischania

Hi Gujal, I've noticed Dailymotion is throwing 403/Cloudflare errors in ResolveURL. I found a workaround that works on Kodi 21. The API now requires a session warm-up to grab valid cookies before requesting metadata. Also, the stream URL needs specific header formatting to avoid 'Demuxer errors' in FFmpeg.

Here is the logic that fixed it for me:
`def playVideo(vid, live=False):
data = getStreamUrl(vid)
if not data:
xbmcgui.Dialog().notification('Dailymotion', 'Αποτυχία λήψης ροής', _icon, 5000)
return

url = data['url']
# Χρήση ενός πολύ βασικού User-Agent
ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/121.0.0.0'

# Κατασκευή του URL με headers για τον FFmpeg
# Προσοχή: Χωρίς καθόλου κενά, μόνο τα απολύτως απαραίτητα
headers = 'User-Agent=' + urllib_parse.quote(ua)
headers += '&Referer=' + urllib_parse.quote('https://www.dailymotion.com/')

if data.get('cookie'):
    headers += '&Cookie=' + urllib_parse.quote(data['cookie'])

full_url = url + '|' + headers

li = xbmcgui.ListItem(path=full_url)
li.setMimeType('video/mp4') # Το δηλώνουμε ως MP4 ακόμα και αν είναι m3u8 για να παρακάμψουμε το ISA
li.setContentLookup(False)

# Επιβολή του εσωτερικού Player
xbmcplugin.setResolvedUrl(pluginhandle, True, listitem=li)

def getStreamUrl(vid):
session = requests.Session()
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/121.0.0.0',
'Referer': 'https://www.dailymotion.com/'
}

try:
    # 1. Πρώτη κλήση για να πάρουμε τα βασικά cookies
    session.get("https://www.dailymotion.com/", headers=headers, timeout=5)
    
    # 2. Κλήση στο metadata API
    api_url = "https://www.dailymotion.com/player/metadata/video/{0}".format(vid)
    r = session.get(api_url, headers=headers, timeout=10)
    content = r.json()
    
    # Λήψη cookies
    cookie_dict = session.cookies.get_dict()
    cookie_str = "; ".join([f"{k}={v}" for k, v in cookie_dict.items()])
    
    qualities = content.get('qualities', {})
    
    # ΠΡΟΤΕΡΑΙΟΤΗΤΑ 1: MP4 (Δεν ζητάει σχεδόν ποτέ ISA)
    for q in ['1080', '720', '480', '380', '240']:
        if q in qualities:
            for source in qualities[q]:
                if source.get('type') == 'video/mp4':
                    return {'url': source.get('url'), 'cookie': cookie_str}

    # ΠΡΟΤΕΡΑΙΟΤΗΤΑ 2: HLS (m3u8) - Μόνο αν δεν υπάρχει MP4
    if 'auto' in qualities:
        return {'url': qualities['auto'][0].get('url'), 'cookie': cookie_str}
        
except Exception as e:
    xbmc.log("DAILYMOTION FINAL ERROR: " + str(e), xbmc.LOGERROR)

return None`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions