[arretsurimages] fix #1691, correctly implement search and add a test
This commit is contained in:
parent
cdb7d6ba49
commit
71347cb8f7
4 changed files with 17 additions and 7 deletions
|
|
@ -46,7 +46,7 @@ class ArretSurImagesBrowser(Browser):
|
|||
def search_videos(self, pattern):
|
||||
self.location(self.buildurl('/emissions.php'))
|
||||
assert self.is_on_page(IndexPage)
|
||||
return self.page.iter_videos()
|
||||
return self.page.iter_videos(pattern)
|
||||
|
||||
@id2url(ArretSurImagesVideo.id2url)
|
||||
def get_video(self, url, video=None):
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class ArretSurImagesModule(Module, CapVideo, CapCollection):
|
|||
BROWSER = ArretSurImagesBrowser
|
||||
|
||||
def create_default_browser(self):
|
||||
return self.create_browser(self.config['login'].get(), self.config['password'].get())
|
||||
return self.create_browser(self.config['login'].get(), self.config['password'].get(), get_home=False)
|
||||
|
||||
def search_videos(self, pattern, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False):
|
||||
with self.browser:
|
||||
|
|
|
|||
|
|
@ -29,10 +29,13 @@ from .video import ArretSurImagesVideo
|
|||
|
||||
|
||||
class IndexPage(Page):
|
||||
def iter_videos(self):
|
||||
def iter_videos(self, pattern=None):
|
||||
videos = self.document.getroot().cssselect("div[class=bloc-contenu-8]")
|
||||
for div in videos:
|
||||
title = self.parser.select(div, 'h1', 1).text_content().replace(' ', ' ')
|
||||
if pattern:
|
||||
if pattern.upper() not in title.upper():
|
||||
continue
|
||||
m = re.match(r'/contenu.php\?id=(.*)', div.find('a').attrib['href'])
|
||||
_id = ''
|
||||
if m:
|
||||
|
|
|
|||
|
|
@ -17,12 +17,19 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.tools.test import BackendTest
|
||||
from weboob.capabilities.video import BaseVideo
|
||||
from weboob.tools.test import BackendTest, SkipTest
|
||||
|
||||
|
||||
class ArretSurImagesTest(BackendTest):
|
||||
MODULE = 'arretsurimages'
|
||||
|
||||
def test_arretsurimages(self):
|
||||
raise NotImplementedError()
|
||||
def test_latest_arretsurimages(self):
|
||||
l = list(self.backend.iter_resources([BaseVideo], [u'latest']))
|
||||
assert len(l)
|
||||
if self.backend.browser.username != u'None':
|
||||
v = l[0]
|
||||
self.backend.fillobj(v, ('url',))
|
||||
self.assertTrue(v.url, 'URL for video "%s" not found' % (v.id))
|
||||
else:
|
||||
raise SkipTest("User credentials not defined")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue