From c05a44d186c1eec480cc2026b0278150b45bde23 Mon Sep 17 00:00:00 2001 From: Sanpi Date: Tue, 7 Mar 2017 09:31:18 +0100 Subject: [PATCH 1/2] [arret-sur-images] Add new extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/loubiana.py | 71 ++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 youtube_dl/extractor/loubiana.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index b056dff53..ab84e371b 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -69,6 +69,7 @@ from .arte import ( TheOperaPlatformIE, ArteTVPlaylistIE, ) +from .loubiana import ArretSurImagesIE from .atresplayer import AtresPlayerIE from .atttechchannel import ATTTechChannelIE from .audimedia import AudiMediaIE diff --git a/youtube_dl/extractor/loubiana.py b/youtube_dl/extractor/loubiana.py new file mode 100644 index 000000000..005ddbe18 --- /dev/null +++ b/youtube_dl/extractor/loubiana.py @@ -0,0 +1,71 @@ +# coding: utf-8 +from __future__ import unicode_literals + +import re + +from .common import InfoExtractor +from ..utils import ( + sanitized_Request, + urlencode_postdata, +) + + +class ArretSurImagesIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?arretsurimages\.net/emissions/.*?-id(?P[0-9]+)' + _LOGIN_URL = 'https://www.arretsurimages.net/forum/login.php' + _TEST = { + 'url': 'https://www.arretsurimages.net/emissions/2017-02-17/Theo-La-matraque-telescopique-beaucoup-de-collegues-l-ont-demandee-id9557', + 'md5': '650d2102dad67b2b6a94ac9c063f6d5b', + 'info_dict': { + 'id': '9557', + 'ext': 'mp4', + 'title': 'Théo : "La matraque télescopique, beaucoup de collègues l\'ont demandée"', + }, + 'skip': 'Requires account credentials', + } + + def _real_initialize(self): + self._login() + + def _login(self): + (username, password) = self._get_login_info() + if username is None: + return + + login_data = urlencode_postdata({ + 'ok': 'Valider', + 'username': username, + 'password': password, + }); + + login_results = self._download_webpage( + sanitized_Request(self._LOGIN_URL, login_data), + None, note='Logging in', errnote='Unable to log in') + + if re.search(r'(?i)Ce nom d\'utilisateur / mot de passe est introuvable ou inactif. Recommencez', login_results) is not None: + self._downloader.report_warning('unable to log in: bad username or password') + return False + + return True + + def _real_extract(self, url): + video_id = self._match_id(url) + + webpage = self._download_webpage(url, video_id) + video_title = self._html_search_regex( + r'

(.*?)

', + webpage, 'title') + download_url = self._html_search_regex( + r'', + webpage, 'download information') + + download_page = self._download_webpage(download_url, video_id, 'Downloading download information page') + video_url = self._html_search_regex( + r'suivre ce lien', + download_page, 'video url') + + return { + 'id': video_id, + 'title': video_title, + 'url': video_url, + } From 62ee9977ab16ff4c69e192d5c4a7294867ab8a3a Mon Sep 17 00:00:00 2001 From: Sanpi Date: Tue, 7 Mar 2017 10:11:01 +0100 Subject: [PATCH 2/2] [hors-serie] Add new extractor --- youtube_dl/extractor/extractors.py | 5 ++- youtube_dl/extractor/loubiana.py | 55 +++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index ab84e371b..4c506da76 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -69,7 +69,10 @@ from .arte import ( TheOperaPlatformIE, ArteTVPlaylistIE, ) -from .loubiana import ArretSurImagesIE +from .loubiana import ( + ArretSurImagesIE, + HorsSerieIE, +) from .atresplayer import AtresPlayerIE from .atttechchannel import ATTTechChannelIE from .audimedia import AudiMediaIE diff --git a/youtube_dl/extractor/loubiana.py b/youtube_dl/extractor/loubiana.py index 005ddbe18..409aad135 100644 --- a/youtube_dl/extractor/loubiana.py +++ b/youtube_dl/extractor/loubiana.py @@ -13,6 +13,9 @@ from ..utils import ( class ArretSurImagesIE(InfoExtractor): _VALID_URL = r'https?://(?:www\.)?arretsurimages\.net/emissions/.*?-id(?P[0-9]+)' _LOGIN_URL = 'https://www.arretsurimages.net/forum/login.php' + _DOWNLOAD_URL = 'https?://v42.arretsurimages.net' + _FILE_URL = 'https?://v42.arretsurimages.net/fichiers' + _TEST = { 'url': 'https://www.arretsurimages.net/emissions/2017-02-17/Theo-La-matraque-telescopique-beaucoup-de-collegues-l-ont-demandee-id9557', 'md5': '650d2102dad67b2b6a94ac9c063f6d5b', @@ -32,36 +35,42 @@ class ArretSurImagesIE(InfoExtractor): if username is None: return - login_data = urlencode_postdata({ - 'ok': 'Valider', - 'username': username, - 'password': password, - }); + login_data = urlencode_postdata(self._get_login_data(username, password)) login_results = self._download_webpage( sanitized_Request(self._LOGIN_URL, login_data), None, note='Logging in', errnote='Unable to log in') - if re.search(r'(?i)Ce nom d\'utilisateur / mot de passe est introuvable ou inactif. Recommencez', login_results) is not None: + if not self._is_logged(login_results): self._downloader.report_warning('unable to log in: bad username or password') return False return True + def _is_logged(self, login_results): + return re.search(r'(?i)Ce nom d\'utilisateur / mot de passe est introuvable ou inactif. Recommencez', login_results) is None + + def _get_login_data(self, username, password): + return { + 'ok': 'Valider', + 'username': username, + 'password': password, + } + def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) video_title = self._html_search_regex( - r'

(.*?)

', + r'

(.*?)

', webpage, 'title') download_url = self._html_search_regex( - r'', + r'suivre ce lien', + r'suivre ce lien', download_page, 'video url') return { @@ -69,3 +78,31 @@ class ArretSurImagesIE(InfoExtractor): 'title': video_title, 'url': video_url, } + + +class HorsSerieIE(ArretSurImagesIE): + _VALID_URL = r'https?://(?:www\.)?hors-serie\.net/.*?-id(?P[0-9]+)' + _LOGIN_URL = 'https://www.hors-serie.net/connexion.php' + _DOWNLOAD_URL = 'https?://v42.hors-serie.net' + _FILE_URL = 'https?://v42.hors-serie.net/fichiers_hs' + + _TEST = { + 'url': 'http://www.hors-serie.net/Dans-le-Texte/2017-01-21/L-effondrement-qui-vient-id211', + 'md5': 'a6aabfe23871146fb55c924e196680c2', + 'info_dict': { + 'id': '211', + 'ext': 'mp4', + 'title': 'L\'effondrement qui vient', + }, + 'skip': 'Requires account credentials', + } + + def _get_login_data(self, username, password): + return { + 'submit': 'valider', + 'mail': username, + 'pass': password, + } + + def _is_logged(self, login_results): + return re.search(r'(?i)Adresse électronique ou mot de passe invalide...', login_results) is None