コード例 #1
0
 def _html_to_json(self, view_html, lecture_id):
     data = parse_json(
         search_regex(
             r'videojs-setup-data=(["\'])(?P<data>{.+?})\1',
             view_html,
             "setup data",
             default="{}",
             group="data",
         ),
         lecture_id,
         transform_source=unescapeHTML,
         fatal=False,
     )
     text_tracks = parse_json(
         search_regex(
             r'text-tracks=(["\'])(?P<data>\[.+?\])\1',
             view_html,
             "text tracks",
             default="{}",
             group="data",
         ),
         lecture_id,
         transform_source=lambda s: js_to_json(unescapeHTML(s)),
         fatal=False,
     )
     return data, text_tracks
コード例 #2
0
ファイル: auth.py プロジェクト: zyy8687/udemy-dl
 def _form_hidden_input(self, form_id):
     try:
         resp = self._cloudsc.get(LOGIN_URL)  # pylint: disable=W
         resp.raise_for_status()
         webpage = resp.text
     except conn_error as error:
         raise error
     else:
         login_form = hidden_inputs(
             search_regex(
                 r'(?is)<form[^>]+?id=(["\'])%s\1[^>]*>(?P<form>.+?)</form>'
                 % form_id,
                 webpage,
                 "%s form" % form_id,
                 group="form",
             )
         )
         login_form.update({"email": self.username, "password": self.password})
         return login_form