From 3cbeff725f9a3ce1a4e3312d9005bac4631d4b41 Mon Sep 17 00:00:00 2001 From: florty2 Date: Tue, 18 Mar 2025 11:48:34 +1100 Subject: [PATCH] Changed to handle mobile site URLs and some others. --- yt_dlp/extractor/myfreecams.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/yt_dlp/extractor/myfreecams.py b/yt_dlp/extractor/myfreecams.py index e0a437191..1f3be5d3b 100644 --- a/yt_dlp/extractor/myfreecams.py +++ b/yt_dlp/extractor/myfreecams.py @@ -1,5 +1,6 @@ import random import re +import socket import urllib.parse from .common import InfoExtractor @@ -8,7 +9,7 @@ class MyFreeCamsIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?myfreecams\.com/#(?P[^/?&#]+)' + _VALID_URL = r'https?:\/\/(?:\w+\.)?myfreecams\.com\/(?:(?:models\/|chats\/)?\#?(?P\w+))' _TESTS = [{ 'url': 'https://www.myfreecams.com/#Elise_wood', 'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)', @@ -25,6 +26,22 @@ class MyFreeCamsIE(InfoExtractor): 'skip_download': True, }, 'skip': 'Model is currently offline', + }, { + 'url': 'https://m.myfreecams.com/chats/Elise_wood', + 'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)', + 'info_dict': { + 'id': 'Elise_wood', + 'ext': 'mp4', + 'title': r're:.*MyFreeCams.*', + 'age_limit': 0, + 'is_live': True, + 'live_status': str, + }, + 'params': { + 'skip_download': True, + }, + 'skip': 'Model is currently offline', + }] JS_SERVER_URL = 'https://www.myfreecams.com/_js/serverconfig.js' @@ -51,7 +68,7 @@ def _websocket_data(self, username, chat_servers): self.write_debug(f'Websocket server {xchat} connected') self.write_debug(f'Websocket URL: {host}') break - except websockets.exceptions.WebSocketException: + except (websockets.exceptions.WebSocketException, socket.gaierror): self.report_warning(f'Failed to connect to WS server: {xchat} - try {try_to_connect + 1}') if try_to_connect == 4: error = f'Failed to connect to WS server: {host}'