From c471981763422ab9a7a7e5577cef07007b9145d5 Mon Sep 17 00:00:00 2001 From: siddht1 Date: Sun, 9 Jul 2017 07:04:01 +0000 Subject: [PATCH] added pornjam.py to add pornjam pornjam.py added,added import to generic.py, added import to extractors.py --- youtube_dl/extractor/extractors.py | 2 + youtube_dl/extractor/generic.py | 1 + youtube_dl/extractor/pornjam.py | 82 ++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 youtube_dl/extractor/pornjam.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index b83c3aba5..436b5dfd1 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1280,6 +1280,7 @@ from .yahoo import ( YahooIE, YahooSearchIE, ) +from .yam import YamIE from .yandexmusic import ( YandexMusicTrackIE, YandexMusicAlbumIE, @@ -1319,3 +1320,4 @@ from .zapiks import ZapiksIE from .zaq1 import Zaq1IE from .zdf import ZDFIE, ZDFChannelIE from .zingmp3 import ZingMp3IE +from .pornjam import PornjamIE \ No newline at end of file diff --git a/youtube_dl/extractor/generic.py b/youtube_dl/extractor/generic.py index f9bff433c..4f9de3936 100644 --- a/youtube_dl/extractor/generic.py +++ b/youtube_dl/extractor/generic.py @@ -91,6 +91,7 @@ from .anvato import AnvatoIE from .washingtonpost import WashingtonPostIE from .wistia import WistiaIE from .mediaset import MediasetIE +from .pornjam import PornjamIE class GenericIE(InfoExtractor): diff --git a/youtube_dl/extractor/pornjam.py b/youtube_dl/extractor/pornjam.py new file mode 100644 index 000000000..51adb7070 --- /dev/null +++ b/youtube_dl/extractor/pornjam.py @@ -0,0 +1,82 @@ +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..compat import compat_urllib_parse_unquote +from ..utils import ( + clean_html, + determine_ext, + ExtractorError, + int_or_none, + parse_duration, +) + + +class PornjamIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?pornjam\.com/video(?P[0-9]+)(?:.*)' + _TEST = { + 'url': 'https://www.pornjam.com/video/rocking-the-room-and-bed/', + 'md5': '', + 'info_dict': { + 'id': '86331', + 'ext': 'mp4', + 'title': 'Rocking the room and bed', + 'duration': 1548, # 25:48 + 'age_limit': 18, + #direct source :https://cdnlw5.videosgratis.tv/videos/8/5/4/4/0/85440ea8900376934eab3692672df0f0e11e35a1.mp4?key=z1pkypF6pH6-z8SLEh-1AiTK2zOD8TXPZeK3ffJM8L4AyPoJ3gvGsi7xmJlK5SPi4JkoI1ooZzrBCKBfpmNRScDz92dA7HATYETMYRtKNxqqq9ERzxVGz_srVrrvPGiV04qCNDwqQ212YWRU1v2DfQMUF-T3piVCb0UuWmknO0GT6-zBlE2EzRfuVWY2-JEho0iBbikj1rbWgBXe71o53g7NhRGlZHDu-l_AZ_MFs0k + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + mobj = re.search(r'

(.+?)

', webpage) + if mobj: + raise ExtractorError('%s said: %s' % (self.IE_NAME, clean_html(mobj.group(1))), expected=True) + + video_title = self._html_search_regex( + r'(.*?)\s+-\s+- Pornjam.com', webpage, 'title') + video_thumbnail = self._search_regex( + r'url_bigthumb=(.+?)&', webpage, 'thumbnail', fatal=False) + video_duration = int_or_none(self._og_search_property( + 'duration', webpage, default=None)) or parse_duration( + self._search_regex( + r'<span[^>]+class=["\']duration["\'][^>]*>.*?(\d[^<]+)', + webpage, 'duration', fatal=False)) + + formats = [] + + video_url = compat_urllib_parse_unquote(self._search_regex( + r'flv_url=(.+?)&', webpage, 'video URL', default='')) + if video_url: + formats.append({ + 'url': video_url, + 'format_id': 'flv', + }) + + for kind, _, format_url in re.findall( + r'setVideo([^(]+)\((["\'])(http.+?)\2\)', webpage): + format_id = kind.lower() + if format_id == 'hls': + formats.extend(self._extract_m3u8_formats( + format_url, video_id, 'mp4', + entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)) + elif format_id in ('urllow', 'urlhigh'): + formats.append({ + 'url': format_url, + 'format_id': '%s-%s' % (determine_ext(format_url, 'mp4'), format_id[3:]), + 'quality': -2 if format_id.endswith('low') else None, + }) + + self._sort_formats(formats) + + return { + 'id': video_id, + 'formats': formats, + 'title': video_title, + 'duration': video_duration, + 'thumbnail': video_thumbnail, + 'age_limit': 18, + }