From bf6705f5840418999582c6cf5cc0e2e47901cf4f Mon Sep 17 00:00:00 2001 From: Saimadhav Heblikar Date: Wed, 15 Jan 2014 11:49:50 +0530 Subject: [PATCH 1/3] Added franceinter [Issue #2105] --- youtube_dl/extractor/franceinter.py | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 youtube_dl/extractor/franceinter.py diff --git a/youtube_dl/extractor/franceinter.py b/youtube_dl/extractor/franceinter.py new file mode 100644 index 000000000..47e06f5a1 --- /dev/null +++ b/youtube_dl/extractor/franceinter.py @@ -0,0 +1,40 @@ +import re + +from .common import InfoExtractor +class FranceInterIE(InfoExtractor): + + _VALID_URL=r'http://www.franceinter.fr/player/reecouter\?play=(?P[0-9]{6})' + IE_NAME='FranceInter' + _TEST={ + u'url':u'http://www.franceinter.fr/player/reecouter?play=793962', + u'file':u'793962.mp3' + + + } + + #Easier to use python string matching than regex for a simple match + def get_download_url(self,webpage): + + start=webpage.index('&urlAOD=')+8 + end=webpage.index('&startTime') + return u'http://www.franceinter.fr/%s'%webpage[start:end] + + def get_title(self,webpage): + start=webpage.index('')+30 + end=webpage.index(' dans') + + return webpage[start:end] + def _real_extract(self,url): + + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + + webpage=self._download_webpage(url,video_id) + + title=self.get_title(webpage) + + video_url=self.get_download_url(webpage) + + return{'id': video_id,u'url': video_url,u'title': title} + + From 14e7543a5a0559086aa33a94557ecb61538c967b Mon Sep 17 00:00:00 2001 From: Saimadhav Heblikar Date: Wed, 15 Jan 2014 11:51:12 +0530 Subject: [PATCH 2/3] franceinter [Issue #2105] Added franceinterIE import to reflect addition of FranceInter support. Issue #2105 --- youtube_dl/extractor/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index b887c7f10..209f327ec 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -61,6 +61,7 @@ from .fktv import ( FKTVPosteckeIE, ) from .flickr import FlickrIE +from .franceinter import FranceInterIE from .francetv import ( PluzzIE, FranceTvInfoIE, From c8650f7ecd4fd253b37103c5581d39ddc37b6337 Mon Sep 17 00:00:00 2001 From: sahutd Date: Wed, 15 Jan 2014 16:48:55 +0530 Subject: [PATCH 3/3] Made modification as suggested on https://github.com/rg3/youtube-dl/pull/2151 --- youtube_dl/extractor/franceinter.py | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/youtube_dl/extractor/franceinter.py b/youtube_dl/extractor/franceinter.py index 47e06f5a1..932a1f161 100644 --- a/youtube_dl/extractor/franceinter.py +++ b/youtube_dl/extractor/franceinter.py @@ -1,29 +1,20 @@ +from __future__ import unicode_literals + import re from .common import InfoExtractor class FranceInterIE(InfoExtractor): - _VALID_URL=r'http://www.franceinter.fr/player/reecouter\?play=(?P[0-9]{6})' - IE_NAME='FranceInter' + _VALID_URL=r'http://(?:www\.)?franceinter\.fr/player/reecouter\?play=(?P[0-9]{6})' _TEST={ u'url':u'http://www.franceinter.fr/player/reecouter?play=793962', u'file':u'793962.mp3' - - + } - #Easier to use python string matching than regex for a simple match - def get_download_url(self,webpage): + - start=webpage.index('&urlAOD=')+8 - end=webpage.index('&startTime') - return u'http://www.franceinter.fr/%s'%webpage[start:end] - - def get_title(self,webpage): - start=webpage.index('')+30 - end=webpage.index(' dans') - - return webpage[start:end] + def _real_extract(self,url): mobj = re.match(self._VALID_URL, url) @@ -31,10 +22,10 @@ class FranceInterIE(InfoExtractor): webpage=self._download_webpage(url,video_id) - title=self.get_title(webpage) + title=self._search_regex(u'(?<=)(.*)(?=)', webpage, u'title') - video_url=self.get_download_url(webpage) + video_url='http://www.franceinter.fr/'+self._search_regex(u'(?<=&urlAOD=)(.*)(?=&startTime)', webpage, u'video url') return{'id': video_id,u'url': video_url,u'title': title} - + \ No newline at end of file