[canalplus] fix play and download
This commit is contained in:
parent
99be5d9e13
commit
e0753f9a23
2 changed files with 18 additions and 12 deletions
|
|
@ -17,7 +17,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import requests
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
import lxml.etree
|
import lxml.etree
|
||||||
|
|
@ -55,8 +55,8 @@ class CanalplusBrowser(BaseBrowser):
|
||||||
#We need lxml.etree.XMLParser to read CDATA
|
#We need lxml.etree.XMLParser to read CDATA
|
||||||
PARSER = XMLParser()
|
PARSER = XMLParser()
|
||||||
FORMATS = {
|
FORMATS = {
|
||||||
'sd': 'BAS_DEBIT',
|
'sd': 0,
|
||||||
'hd': 'HD',
|
'hd': 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, quality, *args, **kwargs):
|
def __init__(self, quality, *args, **kwargs):
|
||||||
|
|
@ -73,7 +73,15 @@ class CanalplusBrowser(BaseBrowser):
|
||||||
@id2url(CanalplusVideo.id2url)
|
@id2url(CanalplusVideo.id2url)
|
||||||
def get_video(self, url, video=None):
|
def get_video(self, url, video=None):
|
||||||
self.location(url)
|
self.location(url)
|
||||||
return self.page.get_video(video, self.quality)
|
video = self.page.get_video(video)
|
||||||
|
video.url = self.read_url(video.url)[self.quality]
|
||||||
|
return video
|
||||||
|
|
||||||
|
def read_url(self, url):
|
||||||
|
r = requests.get(url, stream=True)
|
||||||
|
buf = r.iter_lines()
|
||||||
|
r.close()
|
||||||
|
return [line for line in buf if not line.startswith('#')]
|
||||||
|
|
||||||
def iter_resources(self, split_path):
|
def iter_resources(self, split_path):
|
||||||
if not self.is_on_page(ChannelsPage):
|
if not self.is_on_page(ChannelsPage):
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ class ChannelsPage(BasePage):
|
||||||
|
|
||||||
|
|
||||||
class VideoPage(BasePage):
|
class VideoPage(BasePage):
|
||||||
def parse_video(self, el, video=None, quality=None):
|
def parse_video(self, el, video=None):
|
||||||
_id = el.find('ID').text
|
_id = el.find('ID').text
|
||||||
if _id == '-1':
|
if _id == '-1':
|
||||||
# means the video is not found
|
# means the video is not found
|
||||||
|
|
@ -84,16 +84,14 @@ class VideoPage(BasePage):
|
||||||
video.thumbnail.url = video.thumbnail.id
|
video.thumbnail.url = video.thumbnail.id
|
||||||
else:
|
else:
|
||||||
video.thumbnail = NotAvailable
|
video.thumbnail = NotAvailable
|
||||||
lastest_format = None
|
|
||||||
for format in media.find('VIDEOS'):
|
for format in media.find('VIDEOS'):
|
||||||
if format.text is None:
|
if format.text is None:
|
||||||
continue
|
continue
|
||||||
if format.tag == quality:
|
|
||||||
|
if format.tag == 'HLS':
|
||||||
|
video.ext = u'm3u8'
|
||||||
video.url = unicode(format.text)
|
video.url = unicode(format.text)
|
||||||
break
|
break
|
||||||
lastest_format = format
|
|
||||||
if not video.url and lastest_format is not None:
|
|
||||||
video.url = unicode(lastest_format.text)
|
|
||||||
|
|
||||||
day, month, year = map(int, infos.find('PUBLICATION').find('DATE').text.split('/'))
|
day, month, year = map(int, infos.find('PUBLICATION').find('DATE').text.split('/'))
|
||||||
hour, minute, second = map(int, infos.find('PUBLICATION').find('HEURE').text.split(':'))
|
hour, minute, second = map(int, infos.find('PUBLICATION').find('HEURE').text.split(':'))
|
||||||
|
|
@ -116,9 +114,9 @@ class VideoPage(BasePage):
|
||||||
video.date = datetime.now()
|
video.date = datetime.now()
|
||||||
return video
|
return video
|
||||||
|
|
||||||
def get_video(self, video, quality):
|
def get_video(self, video):
|
||||||
_id = self.group_dict['id']
|
_id = self.group_dict['id']
|
||||||
for vid in self.document.getchildren():
|
for vid in self.document.getchildren():
|
||||||
if not _id in vid.find('ID').text:
|
if not _id in vid.find('ID').text:
|
||||||
continue
|
continue
|
||||||
return self.parse_video(vid, video, quality)
|
return self.parse_video(vid, video)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue