"Onebox Assistant", crawl for those previews reliably!

What it does

Turns this kind of result:

(where your server has failed to bring back the page source so cannot extract the required tags to build the onebox)

Into this!:

It simply provides an alternative path for onebox to get its page source with which to look for meta-data when the target server refuses your connection.

It changes nothing about how onebox then processes the page source to find the meta-data and render the box.

It’s meant to allow you to enter the details and credentials of a third party API to bring back the page instead of doing a normal http call directly to the target page.

Why

I found my servers were being forbidden access to a number of commercial sites so oneboxes would fail to be rendered. It essentiallly helps leverage the trustworthiness of the 3rd party API, a bit like a mail service.

Why it’s cost effective

You can use a relatively cheap VPS but still get reliable one-boxing functionality, even if your IP or user agent is somehow ‘blacklisted’.

You don’t need it if

You are oneboxing all your target content ok with the vanilla install and all users are happy

Pre-requisites

You need an account with a suitable 3rd part API.

Settings

onebox assistant api base address:  https://api.embed.rocks/api/

Above example uses embed.rocks, but in the future support for other API’s might be added, however, embed.rocks is relatively good value atm.

onebox assistant api base query:   ?url=

onebox assistant api options:   &skip=article,description,oembed,imextra&include=source

onebox assistant api page source field:   source

You will also need to enter your API key provided by embed.rocks

See example below

This setting allows you to ignore the prefetch (to check if the direct crawl returns a result) and use the API from the get-go.

image
default OFF

I recommend setting this to TRUE.

This is more expensive of course but often yields better results as there are some cases where the pre-fetch gets redirected to the wrong page because you are not trusted.

Support Information

Remember, if you’ve previously attempted to onebox a link, Discourse core will cache the result.

You can add a random querystring on the end to overcome the cache: https://mylink.com/todaynews?random=random

You can also check the API is responding with, e.g.:

curl -X GET "https://api.embed.rocks/api/?url=https%3A%2F%2Fnews.bbc.co.uk%0A&skip=article,description,oembed,imextra&include=source" -H "x-api-key: %%%your-api-key%%%"

You need to url encode the site you are calling (the url parameter value) using some site like this (not vouched for!)

Known Limitations

  • It’s only been tested with one provider at the moment and not tested on others. That provider is https://embed.rocks (with whom I have no affiliation). I’m happy to consider supporting more services if the work is sponsored.

  • The monkey patching is done at method level. This overrides more code than it needs to which leads to a greater risk of the plugin breaking after a core update. However I don’t think there’s a way to minimise this further?

How to install plugins

See the guide here: Install plugins on a self-hosted site

This repo is: https://github.com/merefield/discourse-onebox-assistant

https://github.com/merefield/discourse-onebox-assistant

All feedback welcome. Please :star: it on GitHub if you find it useful.

41개의 좋아요

죄송합니다. 이 애드온을 활성화한 상태로 사이트를 다시 빌드할 기회가 없었습니다. 오늘 밤에 진행하겠습니다.

@WaitroseCarpark 저는 그런 것을 입력하지 않았습니다. 제가 따랐던 단계는 다음과 같습니다:

1단계:

2단계:

3단계:

4단계:
로봇 확인(캡차) 수행

5단계:
oEmbed API 추가


사인을 포기합니다(ironically)

oEmbed의 초록색 체크 표시

6단계:
설정 > 기본에서 자격 증명(creds) 가져오기

7단계:
앱 토큰(app token) 가져오기

위에서 가져온 자격 증명을 사용하여 다음을 실행합니다.

curl -X GET "https://graph.facebook.com/oauth/access_token?client_id={your-app-id}&client_secret={your-app-secret}&grant_type=client_credentials"

다음과 같은 결과가 반환됩니다.

{"access_token":"378384926723309|xxxxxx","token_type":"bearer"}

인증 토큰 테스트

curl -X GET \ "https://graph.facebook.com/v9.0/instagram_oembed?url=https://www.instagram.com/p/fA9uwTtkSN/&access_token=xxxx..."

다음과 같은 결과가 반환됩니다.

{"version":"1.0","author_name":"diegoquinteiro","provider_name":"Instagram","provider_url":"https:\/\/www.instagram.com\/","type":"rich","width":658,"html":"\u003Cblockquote class=\"instagram-media\" data-instgrm-captioned data-instgrm-permalink=\"https:\/\/www.instagram.com\/p\/fA9uwTtkSN\/?utm_source=ig_embed&utm_campaign=loading\" ....

Discourse에 추가하면 완료입니다!

6개의 좋아요

와…

아, 됐네…

고마워 :bowing_man:

4개의 좋아요

플러그인이 설치된 상태에서요? @Richie

1개의 좋아요

@znedw 이렇게 하나씩 단계별로 (사진까지 첨부해서! :heart_eyes:) 설명해 주셔서 정말 감사합니다! 제가 보기엔 완벽하게 잘 작동합니다!

3개의 좋아요

플러그인이 설치된 상태에서?

1개의 좋아요

방금 이 플러그인을 만든 걸 알게 됐네요… 저는 아직 사용하지 않고 있어서, 다른 분의 스레드를 무단으로 이용해서 죄송합니다.

다만, 오늘 시간이 좀 나면 직접 써볼 생각입니다…

2개의 좋아요

오늘 저녁에 30분 정도 @merefield Robert님, 가능한 모든 조합을 시도해 보았습니다.

@znedw님이 제공해 주신 단계를 따라가 보니(다시 한번 감사드립니다, 형님!), 이 방법은 Onebox Assistant가 활성화된 상태에서도, 비활성화된 상태(관리자 패널 > 플러그인 > 체크박스)에서도 모두 작동하는 것으로 보입니다.

플러그인을 완전히 제거한 상태로 Discourse를 다시 빌드해 보지는 않았습니다.

참고로, 저는 “직접 응답과 관계없이 항상 프록시 크롤을 사용하세요” 옵션을 활성화해 두지 않았습니다.

주제에서 약간 벗어나지만, amazon.co.uk가 다시 모든 종류의 요청을 차단하고 있는 것으로 보입니다. 직접 요청(플러그인 비활성화)뿐 아니라 embed.rocks의 “try it” 페이지를 통한 요청도 타임아웃이 발생하네요 :roll_eyes:

3개의 좋아요

고맙습니다. 네, “항상 프록시를 사용하세요” 옵션이 없어도 작동할 거라고 기대하고 있었습니다.

2개의 좋아요

아마존에 관한 한, 저는 차단되지 않는 제휴 링크를 수동으로 항상 사용하고 있습니다.

제휴 회원이라면 원박스(Oneboxing)를 사용하는 것은 아마존의 약관을 위반합니다.

제휴 회원 가입을 진지하게 고려해 보시길 강력히 추천합니다. 큰 수입은 되지 않지만, 서버 비용과 이메일 비용을 충당하는 데는 도움이 될 수 있습니다.

1개의 좋아요

이 플러그인을 YouTube 링크에만 사용할 수 있을까요? 이 경우 어떤 설정을 사용해야 하는지 이해가 되지 않습니다.
또한 가능한 설정에 대한 추가 정보를 어디서 찾을 수 있나요?
감사합니다!

아니요. 포크를 해서 코드를 추가로 개발해야 합니다.

OP(원본 글)에 있는 내용을 그대로 복사하면 됩니다. 그러면 본인만의 키를 얻게 됩니다.

2개의 좋아요

플러그인이 정상적으로 작동하고 쿼리가 https://embed.rocks를 통해 처리되는지 어떻게 확인할 수 있나요?
활성화했지만 오류가 사라지지 않습니다.

다음 영상으로 테스트해 보았습니다:

https://www.youtube.com/watch?v=_2wfBNUnOVY
https://www.youtube.com/watch?v=qLNhVC296YI
1개의 좋아요

embed.rocks 대시보드에서 호출이 표시되기 시작해야 합니다(로컬 카운터는 있으면 좋지만 아직 구현되지 않았습니다).

두 링크 모두 플러그인을 통해 저에게는 정상적으로 작동합니다.

작동하지 않는다면 다음 옵션을 확인해 보세요:

image

2개의 좋아요

지금까지 말씀하신 모든 설정이 이미지에 나와 있는 것과 동일한가요? 제가 설정을 입력할 때 실수가 있었을 수도 있습니다. 설정을 복사할 수 있는 방법이 있을까요?

1개의 좋아요

OP에 평문(plaintext)을 추가해 두었습니다.

3개의 좋아요

감사합니다. 확인해 보니 모든 것이 정상이었습니다. 사용량 섹션의 대시보드 페이지에서 호출 기록이 보이지 않습니다. 무언가 잘못된 건가요? 호출 수가 항상 표시되어야 하나요?

1개의 좋아요

그 질문은 embed.rocks에 직접 물어보셔야 할 것 같습니다. 추후 플러그인에 추가 로그 기록 기능을 넣을 수도 있으니, 도움이 될 수도 있습니다. 또한 기존에 Rails.logger.info 호출이 이미 존재하므로, 사이트의 로그 수준을 'info’로 설정하면 더 많은 정보를 얻을 수 있을 것입니다.

1개의 좋아요

네, 그러면 좋겠어요. 그런데 방금 플러그인을 활성화하고 설정을 구성했는데, 유튜브가 작동하지 않고 대시보드에도 활동이 없습니다. embed.rocks 지원팀에 이메일을 보냈어요.

1개의 좋아요

Amazon S3에 파일을 저장하는 경우 이 플러그인이 정상적으로 작동할까요?
아직도 어려움을 겪고 있으며, 제대로 작동하지 않습니다. 영상이 업로드되지 않고 링크만 생성됩니다. 또한 Embed.rocks 의 사용량 패널에 정보가 표시되지 않습니다.

테스트 서버를 하나 보유하고 있으며, 파일은 해당 서버에 로컬로 저장되어 있습니다. 하지만 이 경우에도 플러그인이 작동하지 않고 사용량 대시보드에 활동 기록이 없습니다. 다만 영상은 사이트에 저장되기는 합니다.

문제를 해결하기 위해 무엇을 어떻게 확인해야 하는지 이해가 되지 않습니다.

아이디어나 조언을 주시면 감사하겠습니다.

2개의 좋아요