Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to show title on top of URL? #35

Open
TheMithuRoy opened this issue Jul 16, 2021 · 3 comments
Open

Is it possible to show title on top of URL? #35

TheMithuRoy opened this issue Jul 16, 2021 · 3 comments

Comments

@TheMithuRoy
Copy link

Is it possible to display the og:title on top of the URL? Instead of showing YouTube Video, the video title may show up. And instead of displaying the full link, just the hostname would be really nice.

@lazy-coder-10
Copy link

Yes it is possible. you i have to import library and make changes in LinkPreview.kt file.

@NickM-27
Copy link
Owner

If you make this change and do a pr I'd be happy to accept it

@lazy-coder-10
Copy link

lazy-coder-10 commented Jul 22, 2021

Okay, I will try if I got the time to do but in the meantime if someone is not able to fetch the youtube title you just need to remove the below code and the else condition code will be outside the else branch. so that means jsoup will fetch the title and image from the youtube URL as well as the normal URL. That is work for me.

LinkPreview.Kt
if (url.let { it.contains("youtube") && it.contains("v=") }) { val id = url.split("v=")[1].split(" ")[0] val imageUrl = "https://img.youtube.com/vi/$id/hqdefault.jpg" imageType = ImageType.YOUTUBE context.addLink(url, imageUrl) setPreviewData(PreviewData("Youtube Video",imageUrl,url)) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants