[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
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import requests
|
||||
import urllib
|
||||
|
||||
import lxml.etree
|
||||
|
|
@ -55,8 +55,8 @@ class CanalplusBrowser(BaseBrowser):
|
|||
#We need lxml.etree.XMLParser to read CDATA
|
||||
PARSER = XMLParser()
|
||||
FORMATS = {
|
||||
'sd': 'BAS_DEBIT',
|
||||
'hd': 'HD',
|
||||
'sd': 0,
|
||||
'hd': 3,
|
||||
}
|
||||
|
||||
def __init__(self, quality, *args, **kwargs):
|
||||
|
|
@ -73,7 +73,15 @@ class CanalplusBrowser(BaseBrowser):
|
|||
@id2url(CanalplusVideo.id2url)
|
||||
def get_video(self, url, video=None):
|
||||
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):
|
||||
if not self.is_on_page(ChannelsPage):
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class ChannelsPage(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
|
||||
if _id == '-1':
|
||||
# means the video is not found
|
||||
|
|
@ -84,16 +84,14 @@ class VideoPage(BasePage):
|
|||
video.thumbnail.url = video.thumbnail.id
|
||||
else:
|
||||
video.thumbnail = NotAvailable
|
||||
lastest_format = None
|
||||
for format in media.find('VIDEOS'):
|
||||
if format.text is None:
|
||||
continue
|
||||
if format.tag == quality:
|
||||
|
||||
if format.tag == 'HLS':
|
||||
video.ext = u'm3u8'
|
||||
video.url = unicode(format.text)
|
||||
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('/'))
|
||||
hour, minute, second = map(int, infos.find('PUBLICATION').find('HEURE').text.split(':'))
|
||||
|
|
@ -116,9 +114,9 @@ class VideoPage(BasePage):
|
|||
video.date = datetime.now()
|
||||
return video
|
||||
|
||||
def get_video(self, video, quality):
|
||||
def get_video(self, video):
|
||||
_id = self.group_dict['id']
|
||||
for vid in self.document.getchildren():
|
||||
if not _id in vid.find('ID').text:
|
||||
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