From 5ca7aa42862a8c5dfc617c7d04dc40b112abcec6 Mon Sep 17 00:00:00 2001
From: Mr Scrapy <jsmith6669993@gmail.com>
Date: Sat, 22 Oct 2022 17:53:43 +0100
Subject: [PATCH] Add Recurbate premium support

---
 youtube_dl/extractor/extractors.py |  1 +
 youtube_dl/extractor/recurbate.py  | 34 ++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
 create mode 100644 youtube_dl/extractor/recurbate.py

diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py
index 751fc38b6..741ae437d 100644
--- a/youtube_dl/extractor/extractors.py
+++ b/youtube_dl/extractor/extractors.py
@@ -1007,6 +1007,7 @@ from .raywenderlich import (
 )
 from .rbmaradio import RBMARadioIE
 from .rds import RDSIE
+from .recurbate import RecurbateIE
 from .redbulltv import (
     RedBullTVIE,
     RedBullEmbedIE,
diff --git a/youtube_dl/extractor/recurbate.py b/youtube_dl/extractor/recurbate.py
new file mode 100644
index 000000000..4e7e0afba
--- /dev/null
+++ b/youtube_dl/extractor/recurbate.py
@@ -0,0 +1,34 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+
+class RecurbateIE(InfoExtractor):
+    _VALID_URL = r'https?:\/\/(?:www\.)?recurbate\.com\/play\.php\?video=(?P<id>[0-9]+)'
+    _TEST = {
+        'url': 'https://recurbate.com/play.php?video=38825900',
+        'info_dict': {
+            'id': '38825900',
+            'ext': 'mp4',
+            'title': 'Performer vvendy show on 2022-10-21 16:55, Chaturbate Archive – Recurbate'
+        },
+        'skip': 'Requires premium subscription cookie session',
+    }
+
+    def _real_extract(self, url):
+        video_id = self._match_id(url)
+        webpage = self._download_webpage(url, video_id)
+
+        title = self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title')
+        token = self._html_search_regex(r'data-token=(.+?")', webpage, 'play_button').strip("\"")
+        get_url = f"https://recurbate.com/api/get.php?video={video_id}&token={token}"
+        video_webpage = self._download_webpage(get_url, video_id)
+        real_url = self._html_search_regex(r'<source src=(.+?) type=\"video\/mp4\"', video_webpage, 'mp4video').strip("\"")
+
+        return {
+            'id': video_id,
+            'title': title,
+            'description': self._og_search_description(webpage),
+            'url': real_url,
+        }