Preparing git repo for final project
This commit is contained in:
20
problems/pset7/watch/watch.py
Normal file
20
problems/pset7/watch/watch.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import re
|
||||
|
||||
youtube_regex = re.compile(r"<iframe.*https?://(?:www\.)?youtube\.com/embed/(\w+).*</iframe>")
|
||||
|
||||
|
||||
def main():
|
||||
print(parse(input("HTML: ")))
|
||||
|
||||
|
||||
def parse(s):
|
||||
video_id = youtube_regex.search(s)
|
||||
if video_id:
|
||||
video_id = video_id.groups()[0]
|
||||
else:
|
||||
return None
|
||||
return f"https://youtu.be/{video_id}"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user