We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cc8d2a7 commit 979be0dCopy full SHA for 979be0d
week-7/watch/watch.py
@@ -0,0 +1,27 @@
1
+import re
2
+
3
4
+def main():
5
+ print(parse(input("HTML: ")))
6
7
8
+def parse(s):
9
+ """
10
+ this function take an youtube iframe like and return short version of link
11
12
13
+ # - user walrus -
14
+ # if src_link := re.search(r"^<iframe(?:.+)? src=\"(?:https?://)?(?:www\.)?youtube.com/embed/(\w+)\".?(?:.+)?></iframe>$", s):
15
+ # return f"https://youtu.be/{src_link.group(1)}"
16
+ # return None
17
18
19
+ # - normal way -
20
+ src_link = re.search(r"^<iframe(?:.+)? src=\"(?:https?://)?(?:www\.)?youtube.com/embed/(\w+)\".?(?:.+)?></iframe>$", s):
21
+ if src_link:
22
+ return f"https://youtu.be/{src_link.group(1)}"
23
+ return None
24
25
26
+if __name__ == "__main__":
27
+ main()
0 commit comments