pax_global_header 0000666 0000000 0000000 00000000064 13436457030 0014517 g ustar 00root root 0000000 0000000 52 comment=3863a14eedf17551743a8bbccf0237874d7f4a16
woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-funmooc/ 0000775 0000000 0000000 00000000000 13436457030 0022524 5 ustar 00root root 0000000 0000000 woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-funmooc/modules/ 0000775 0000000 0000000 00000000000 13436457030 0024174 5 ustar 00root root 0000000 0000000 woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-funmooc/modules/funmooc/ 0000775 0000000 0000000 00000000000 13436457030 0025642 5 ustar 00root root 0000000 0000000 woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-funmooc/modules/funmooc/__init__.py 0000664 0000000 0000000 00000001511 13436457030 0027751 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2015 Vincent A
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from .module import FunmoocModule
__all__ = ['FunmoocModule']
woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-funmooc/modules/funmooc/browser.py 0000664 0000000 0000000 00000007763 13436457030 0027714 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2015 Vincent A
#
# This file is part of a weboob module.
#
# This weboob module is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This weboob module is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this weboob module. If not, see .
from __future__ import unicode_literals
from weboob.browser import LoginBrowser, URL, need_login
from weboob.browser.exceptions import HTTPNotFound
from weboob.exceptions import BrowserIncorrectPassword
from weboob.capabilities.image import Thumbnail
from .pages import PageLogin, PageDashboard, PageChapter, PageSection
from .video import MoocVideo
import re
class FunmoocBrowser(LoginBrowser):
BASEURL = 'https://www.fun-mooc.fr'
login = URL('/login', '/login_ajax', PageLogin)
dashboard = URL('/dashboard', PageDashboard)
course = URL('/courses/(?P[^/]+/[^/]+/[^/]+)/courseware/?$',
'/courses/(?P[^/]+/[^/]+/[^/]+)/info/?$',
PageChapter)
chapter = URL('/courses/(?P[^/]+/[^/]+/[^/]+)/courseware'
'/(?P[0-9a-f]+)/$', PageChapter)
section = URL('/courses/(?P[^/]+/[^/]+/[^/]+)/courseware/'
'(?P[0-9a-f]+)/(?P[0-9a-f]+)/$', PageSection)
file = URL(r'https://.*\.cloudfront\.net/videos/(?P[^/]+)/'
r'(?P\w+)\.mp4')
def __init__(self, username, password, quality='hd', *args, **kwargs):
super(FunmoocBrowser, self).__init__(username, password, *args, **kwargs)
self.quality = quality
def do_login(self):
self.login.stay_or_go()
csrf = self.session.cookies.get('csrftoken')
self.page.login(self.username, self.password, csrf)
self.dashboard.stay_or_go()
if not self.page.logged:
raise BrowserIncorrectPassword()
def get_video(self, url):
v = MoocVideo(url)
v.url = url
v.ext = 'mp4'
v.title = re.sub(r'[:/"]', '-', url)
return v
@need_login
def iter_videos(self, course, chapter, section):
course = course.replace('-', '/')
assert self.section.stay_or_go(course=course, chapter=chapter, section=section)
for n, d in enumerate(self.page.iter_videos()):
video = self.get_video(d['url'])
if d.get('thumbnail'):
video.thumbnail = Thumbnail(d['thumbnail'])
if d.get('title'):
video.title = d['title']
yield video
@need_login
def iter_sections(self, courseid, chapter):
course = courseid.replace('-', '/')
assert self.chapter.stay_or_go(course=course, chapter=chapter)
for coll in self.page.iter_sections():
if coll.split_path[:2] == [courseid, chapter]:
yield coll
@need_login
def iter_chapters(self, courseid):
course = courseid.replace('-', '/')
assert self.course.stay_or_go(course=course)
return self.page.iter_chapters()
@need_login
def iter_courses(self):
assert self.dashboard.stay_or_go()
return self.page.iter_courses()
@need_login
def check_collection(self, path):
if len(path) == 0:
return True
elif len(path) > 3:
return False
parts = list(zip(('course', 'chapter', 'section'), path))
parts[0] = (parts[0][0], parts[0][1].replace('-', '/'))
try:
getattr(self, parts[-1][0]).open(**dict(parts))
except HTTPNotFound:
return False
return True
woob-3863a14eedf17551743a8bbccf0237874d7f4a16-modules-funmooc/modules/funmooc/favicon.png 0000664 0000000 0000000 00000004043 13436457030 0027776 0 ustar 00root root 0000000 0000000 PNG
IHDR @ @ iq bKGD pHYs tIME
Ku tEXtComment Created with GIMPW IDATxlTE?Gz@-G9R@~A
rP9&hA$-vH-(#䐻3**bOP-Q+-Pls-Ǽ*d2f3;|Y2A
fg"`$pXi x0t)92 Ҁ@_
@59p(
DfuϺ &H/Uܭ[Sr~`w0 J\STZ?mK 2|'~-3tl@J,A^A
ӚSO'l EJ4á߿'XZ<HR. @%P9U1j,
lv:<c*Vϙ`fmNž6*xU7?6uf#e%yHz躷}@ݸ8`3@ rą8AݸOY]ɯ8f$ڍUkgR9g4t~2x>Zt[2QN|LU|:V]bDa,1Q]
dhiP)vQsBRsTʹ :ɤpUΟJ[Ih:wL=鮂E=esB}rJש,Ih|. }T`xY}F?"ӆGLkUXߧ *)د5--R mëpƀ\B&%,wn]W5rɌ$^Mj}n0`4D*3 Hb?NLo55u?ugs3TaR.+_ֆ>1)L.ޚC=NI8*|\g p"yt5P3hJVM@ݢ7totmfـ