Skip to content

Commit

Permalink
more solid regex system, fixed Silab issue no3
Browse files Browse the repository at this point in the history
  • Loading branch information
sgorblex committed May 23, 2021
1 parent 782eb11 commit 00a38bf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion unimi_dl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# along with unimi-dl. If not, see <https://www.gnu.org/licenses/>.


__version__ = "0.2.1"
__version__ = "0.2.3"
__license__ = "GPL v.3"

import unimi_dl.platform
Expand Down
16 changes: 6 additions & 10 deletions unimi_dl/platform/ariel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@ def get_manifests(self, url: str) -> list[tuple[str, str]]:
self.logger.info("Getting video page")
video_page = self.session.get(url).text

self.logger.info("Collecting manifests")
manifest_re = re.compile(r"https://.*/manifest\.m3u8")
match = manifest_re.findall(video_page)

self.logger.info("Collecting manifests and video names")
res = []
filename_re = re.compile(
r"https://videolectures.unimi.it/vod/mp4:(.*?)\..*?/manifest.m3u8")
self.logger.info("Fetching video names")
for manifest in match:
filename = urllib.parse.unquote(filename_re.search(manifest)[1])
res.append((filename, manifest))
manifest_re = re.compile(
r"https://.*?/mp4:.*?([^/]*?)\.mp4/manifest.m3u8")
for i, manifest in enumerate(manifest_re.finditer(video_page)):
res.append((urllib.parse.unquote(
manifest[1]) if manifest[1] else urllib.parse.urlparse(url)[1]+str(i), manifest[0]))
return res
17 changes: 12 additions & 5 deletions unimi_dl/platform/panopto.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import requests
from urllib3 import disable_warnings
import urllib.parse
from urllib3.exceptions import InsecureRequestWarning

from .ariel import get_ariel_session
Expand Down Expand Up @@ -53,11 +54,17 @@ def get_manifests(self, url: str) -> list[tuple[str, str]]:
manifest_page = self.session.get(iframe_url).text

self.logger.info("Collecting manifests")
manifest_re = re.compile(r"\"VideoUrl\":\"(https:.*?\.m3u8)\"")
manifest = manifest_re.search(manifest_page)[1].replace("\\", "")
manifest = re.compile(
r"\"VideoUrl\":\"(https:.*?\.m3u8)\"").search(manifest_page)
if not manifest:
self.logger.info("No manifest found")
return []

self.logger.info("Fetching video names")
title_re = re.compile(r"<title>(.*?)</title>")
filename = title_re.search(manifest_page)[1]
filename_match = re.compile(
r"<title>(.*?)</title>").search(manifest_page)

return [(filename, manifest)]
filename = filename_match[1] if filename_match and filename_match[1] else urllib.parse.urlparse(url)[
1]

return [(filename, manifest[1].replace("\\", ""))]

0 comments on commit 00a38bf

Please sign in to comment.