New video embedding
This commit is contained in:
		
							parent
							
								
									13f1d2f390
								
							
						
					
					
						commit
						b31c286a8b
					
				@ -91,10 +91,10 @@ def embed_youtube(text):
 | 
				
			|||||||
    for element in soup.find_all("a"):
 | 
					    for element in soup.find_all("a"):
 | 
				
			||||||
        if (
 | 
					        if (
 | 
				
			||||||
            element.attrs["href"].startswith("https://www.you")
 | 
					            element.attrs["href"].startswith("https://www.you")
 | 
				
			||||||
            and "?v=" in element.attrs["href"]
 | 
					            and "v=" in element.attrs["href"] or "si=" in element.attrs["href"]
 | 
				
			||||||
        ):
 | 
					        ):
 | 
				
			||||||
            video_name = element.attrs["href"].split("?v=")[1].split("&")[0]
 | 
					            video_name = "?" + "?".join(element.attrs["href"].split("?")[1:])
 | 
				
			||||||
            embed_template = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_name}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>'
 | 
					            embed_template = f'<br /><iframe width="560" height="315" src="https://www.youtube.com/embed/{video_name}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>'
 | 
				
			||||||
            element.replace_with(BeautifulSoup(embed_template, "html.parser"))
 | 
					            element.replace_with(BeautifulSoup(embed_template, "html.parser"))
 | 
				
			||||||
    return str(soup)
 | 
					    return str(soup)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user