問題があり、解決策が見つかりません。今はたくさん検索しましたが、どうすれば修正できるのかわかりません。
このエラーが発生します:
TypeError: cannot parse from 'tuple'
ラインのために link1 = lxml.html.parse(links[0])
私のコード:
if "https://youtube.com" in message.content or "https://www.youtube.com" in message.content or "https://youtu.be" in message.content:
link = f"{message.content}"
links = re.findall('http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?', link)
link1 = lxml.html.parse(links[0])
link2 = link1.find(".//title").text
title = link2.replace(" - YouTube", "")
Thumbnail = f"https://img.youtube.com/vi/{links[0][0]}/mqdefault.jpg"
embed.set_image(url=Thumbnail)
embed.add_field(name="<:YouTube:800381737489924106> | Video anschauen", value=f"**[{title}]({links})**")
パターンには1つ以上のグループre.findall
があるため、一致するタプルのリストを返します。URLを更新する場合は、パターンを更新します。
links = re.findall('(http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)(&(amp;)?[\w\?=]*)?)', link)
link1 = lxml.html.parse(links[0][0])
...
Thumbnail = f"https://img.youtube.com/vi/{links[0][1]}/mqdefault.jpg"
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加