forked from MarseyWorld/MarseyWorld
fsd
parent
b4dc5cb089
commit
aebb90e8b0
|
@ -199,9 +199,9 @@ def sanitize(sanitized, noimages=False):
|
|||
elif path.isfile(f'files/assets/images/emojis/{emoji}.webp'):
|
||||
sanitized = re.sub(f'(?<!"):{emoji}:', f'<img loading="lazy" data-bs-toggle="tooltip" alt=":{emoji}:" title=":{emoji}:" delay="0" height=30 class="emoji" src="/static/assets/images/emojis/{emoji}.webp">', sanitized, flags=re.I)
|
||||
|
||||
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?a=").replace("https://music.youtube.com/watch?a=", "https://youtube.com/watch?a=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?a=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube")
|
||||
sanitized = sanitized.replace("https://www.", "https://").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube")
|
||||
|
||||
if "https://youtube.com/watch?a=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
|
||||
if "https://youtube.com/watch?v=" in sanitized: sanitized = sanitized.replace("?t=", "&t=")
|
||||
|
||||
for i in re.finditer('" target="_blank">(https://youtube\.com/watch\?v\=(.*?))</a>', sanitized):
|
||||
url = i.group(1)
|
||||
|
|
|
@ -749,7 +749,7 @@ def submit_post(v):
|
|||
for rd in ["https://reddit.com/", "https://new.reddit.com/", "https://www.reddit.com/", "https://redd.it/"]:
|
||||
url = url.replace(rd, "https://old.reddit.com/")
|
||||
|
||||
url = url.replace("old.reddit.com/gallery", "new.reddit.com/gallery").replace("https://youtu.be/", "https://youtube.com/watch?a=").replace("https://music.youtube.com/watch?a=", "https://youtube.com/watch?a=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?a=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube")
|
||||
url = url.replace("old.reddit.com/gallery", "new.reddit.com/gallery").replace("https://youtu.be/", "https://youtube.com/watch?v=").replace("https://music.youtube.com/watch?v=", "https://youtube.com/watch?v=").replace("https://open.spotify.com/", "https://open.spotify.com/embed/").replace("https://streamable.com/", "https://streamable.com/e/").replace("https://youtube.com/shorts/", "https://youtube.com/watch?v=").replace("https://mobile.twitter", "https://twitter").replace("https://m.facebook", "https://facebook").replace("m.wikipedia.org", "wikipedia.org").replace("https://m.youtube", "https://youtube").replace("https://www.youtube", "https://youtube")
|
||||
|
||||
if url.startswith("https://streamable.com/") and not url.startswith("https://streamable.com/e/"): url = url.replace("https://streamable.com/", "https://streamable.com/e/")
|
||||
|
||||
|
@ -785,8 +785,8 @@ def submit_post(v):
|
|||
elif "twitter.com" == domain:
|
||||
try: embed = requests.get("https://publish.twitter.com/oembed", timeout=5, params={"url":url, "omit_script":"t"}).json()["html"]
|
||||
except: embed = None
|
||||
elif url.startswith('https://youtube.com/watch?a='):
|
||||
yt_id = url.split('https://youtube.com/watch?a=')[1].split('&')[0].split('%')[0]
|
||||
elif url.startswith('https://youtube.com/watch?v='):
|
||||
yt_id = url.split('https://youtube.com/watch?v=')[1].split('&')[0].split('%')[0]
|
||||
params = parse_qs(urlparse(url).query)
|
||||
t = params.get('t', params.get('start', [0]))[0]
|
||||
if isinstance(t, str): t = t.replace('s','')
|
||||
|
|
|
@ -1046,7 +1046,7 @@ def settings_song_change(v):
|
|||
return redirect("/settings/profile")
|
||||
|
||||
song = song.replace("https://music.youtube.com", "https://youtube.com")
|
||||
if song.startswith(("https://www.youtube.com/watch?a=", "https://youtube.com/watch?a=", "https://m.youtube.com/watch?a=")):
|
||||
if song.startswith(("https://www.youtube.com/watch?v=", "https://youtube.com/watch?v=", "https://m.youtube.com/watch?v=")):
|
||||
id = song.split("v=")[1]
|
||||
elif song.startswith("https://youtu.be/"):
|
||||
id = song.split("https://youtu.be/")[1]
|
||||
|
@ -1099,7 +1099,7 @@ def settings_song_change(v):
|
|||
}
|
||||
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
try: ydl.download([f"https://youtube.com/watch?a={id}"])
|
||||
try: ydl.download([f"https://youtube.com/watch?v={id}"])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
if not v or v.oldsite: template = ''
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<p class="text-gray-500 mb-3">
|
||||
go spam somewhere else nerd
|
||||
</p>
|
||||
<a href="https://www.youtube.com/watch?a=1" class="btn btn-gray">Go to frontpage</a>
|
||||
<a href="https://www.youtube.com/watch?v=1" class="btn btn-gray">Go to frontpage</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<hr class="my-2 border-t border-gray-300 dark:border-gray-900 h-1 shadow-inset-t-white-10"/>
|
||||
<a href="https://www.youtube.com/watch?a=1" target="_blank">
|
||||
<a href="https://www.youtube.com/watch?v=1" target="_blank">
|
||||
<img src="https://media0.giphy.com/media/3o72FhIuVWddxQHftS/giphy.gif" class="sticky top-4 w-full h-58 object-contain p-[3px] bg-white lozad" alt="cozy fireplace log fire"/>
|
||||
</a>
|
||||
</div>
|
|
@ -58,7 +58,7 @@ You can use Markdown formatting:
|
|||
</tr>
|
||||
<tr>
|
||||
<td>Youtube Videos</td>
|
||||
<td>https://youtube.com/watch?a=3Hecr51ByE4</td>
|
||||
<td>https://youtube.com/watch?v=3Hecr51ByE4</td>
|
||||
<td><lite-youtube videoid="3Hecr51ByE4" params="controls=0&modestbranding=1"></lite-youtube></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
Loading…
Reference in New Issue