„Onebox Assistant“, crawle zuverlässig nach diesen Vorschauen!

Was es tut

Verwandelt dieses Ergebnis:

(wobei Ihr Server die Seitenquelle nicht abrufen konnte und daher die erforderlichen Tags zum Erstellen der Onebox nicht extrahieren konnte)

In dieses hier!:

Es bietet einfach einen alternativen Pfad für die Onebox, um ihre Seitenquelle zu erhalten, mit der sie nach Metadaten suchen kann, wenn der Zielservers die Verbindung verweigert.

Es ändert nichts daran, wie die Onebox die Seitenquelle dann verarbeitet, um Metadaten zu finden und die Box darzustellen.

Es soll Ihnen ermöglichen, die Details und Zugangsdaten einer Drittanbieter-API einzugeben, um die Seite abzurufen, anstatt einen normalen HTTP-Aufruf direkt an die Zielseite zu tätigen.

Warum

Ich stellte fest, dass meine Server den Zugriff auf eine Reihe kommerzieller Websites verweigert wurde, sodass Oneboxes nicht gerendert werden konnten. Es hilft im Wesentlichen, die Vertrauenswürdigkeit der Drittanbieter-API zu nutzen, ähnlich wie ein E-Mail-Dienst.

Warum es kosteneffektiv ist

Sie können einen relativ günstigen VPS verwenden und erhalten dennoch eine zuverlässige Onebox-Funktionalität, selbst wenn Ihre IP-Adresse oder Ihr User-Agent irgendwie „schwarzgelistet" sind.

Sie brauchen es nicht, wenn

Sie alle Ihre Zielinhalte mit der Standardinstallation einwandfrei als Onebox darstellen und alle Benutzer zufrieden sind.

Voraussetzungen

Sie benötigen ein Konto bei einer geeigneten Drittanbieter-API.

Einstellungen

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

Das obige Beispiel verwendet embed.rocks, aber in Zukunft könnte die Unterstützung für andere APIs hinzugefügt werden. Derzeit ist embed.rocks jedoch relativ preiswert.

onebox assistant api base query:   ?url=

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

onebox assistant api page source field:   source

Sie müssen auch Ihren von embed.rocks bereitgestellten API-Schlüssel eingeben.

Siehe Beispiel unten:

Diese Einstellung ermöglicht es Ihnen, das Vorabladen (um zu prüfen, ob der direkte Crawl ein Ergebnis liefert) zu ignorieren und die API von Anfang an zu verwenden.

image
Standardmäßig AUS.

Ich empfehle, dies auf WAHR zu setzen.

Dies ist natürlich teurer, liefert aber oft bessere Ergebnisse, da es Fälle gibt, in denen das Vorabladen auf die falsche Seite umgeleitet wird, weil Sie nicht vertrauenswürdig sind.

Support-Informationen

Denken Sie daran: Wenn Sie zuvor versucht haben, einen Link als Onebox darzustellen, zwischenspeichert Discourse Core das Ergebnis.

Sie können am Ende eine zufällige Abfragezeichenfolge hinzufügen, um den Cache zu umgehen: https://mylink.com/todaynews?random=random

Sie können auch prüfen, ob die API antwortet, z. B. mit:

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%%%"

Sie müssen die aufgerufene Website (den Wert des Parameters url) mit einer Site wie dieser wie hier (nicht empfohlen!) URL-kodieren.

Bekannte Einschränkungen

  • Es wurde bisher nur mit einem Anbieter getestet und nicht mit anderen. Dieser Anbieter ist https://embed.rocks (mit dem ich keine Verbindung habe). Ich bin gerne bereit, weitere Dienste zu unterstützen, wenn die Arbeit gesponsert wird.

  • Das Monkey-Patching erfolgt auf Methodenebene. Dies überschreibt mehr Code als nötig, was zu einem höheren Risiko führt, dass das Plugin nach einem Core-Update nicht mehr funktioniert. Ich denke jedoch nicht, dass es eine Möglichkeit gibt, dies weiter zu minimieren?

Wie man Plugins installiert

Siehe die Anleitung hier: Install plugins on a self-hosted site

Dieses Repository ist: https://github.com/merefield/discourse-onebox-assistant

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

Alle Rückmeldungen sind willkommen. Bitte :star: es auf GitHub, wenn Sie es nützlich finden.

41 „Gefällt mir“

Sorry I haven’t had a chance to rebuild our site with this addon enabled, I’ll do so tonight.

@WaitroseCarpark I didn’t fill out anything like that, steps I followed are:

Step 1:

Step 2:

Step 3:

Step 4:
do the robot check

Step 5:
add oEmbed api


sign your life away
image
green tick for oEmbed
image

Step 6:
get creds from Settings > Basic

Step 7:
get an app token

with the creds from above, run

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

which returns

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

test your auth token

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

which returns

{"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\" ....

Add to discourse and you’re done!

6 „Gefällt mir“

Wow…

Ok, that worked…

Thanks man :bowing_man:

4 „Gefällt mir“

With the plugin installed? @Richie

1 „Gefällt mir“

@znedw Thank you so much for taking the time to explain step by step (with pictures! :heart_eyes:) how to do this! Works a charm as far as I can see!

3 „Gefällt mir“

with the plugin installed?

1 „Gefällt mir“

I only actually noticed you’ve made this plugin just now…I was not using it, sorry for hijacking your thread.

BUT, I will try it out later today if I can find some spare time…

2 „Gefällt mir“

I spent half an hour or so this evening trying all manner of possible permutations, Robert @merefield

Following the steps provided by @znedw (thanks again my man!) it would appear that this method works both with the Onebox Assistant enabled, and with it disabled too (via admin panel, plugins, checkbox).

I’ve not tried rebuilding my Discourse with the plugin completely removed.

Perhaps worth a note, I do not have the option enabled for “Always use the proxy crawl regardless of direct response”.

Off topic, it would appear amazon.co.uk are blocking all manner of requests again, both directly (plugin disabled) and also via embed.rocks “try it” page, which also times out :roll_eyes:

3 „Gefällt mir“

Thanks. Yes I expected it to work at least without the “always use the proxy”

2 „Gefällt mir“

On the subject of Amazon I always use their affiliate links anyway, manually, which are not blocked.

Oneboxing breaches their T&Cs if you are an affiliate.

Highly recommend you consider the affiliate membership. It doesn’t net a fortune but may pay for the server and mail fees.

1 „Gefällt mir“

Is it possible to use this plugin only for YouTube links? Can’t understand what settings should I use for this.
And also where can I find more info about possible settings?
Thank you!

No. You’d have to fork and develop the code further.

Just copy those in the OP exactly. You will have your own key.

2 „Gefällt mir“

How can I check if the plugin working and the queries are going through https://embed.rocks?
I activated it, but the error hasn’t gone.

I test with these videos:

https://www.youtube.com/watch?v=_2wfBNUnOVY
https://www.youtube.com/watch?v=qLNhVC296YI
1 „Gefällt mir“

The dashboard on embed.rocks should start reflecting your calls (a local counter is a nice-to-have but have not yet implemented one)

Both of those links work for me via the plugin.

If it’s not working, try checking this option:

image

2 „Gefällt mir“

Are all settings you have equal to those in the picture you gave? Maybe I have a mistake when typing them. Any option to copy them?

1 „Gefällt mir“

I’ve added plaintext to the OP for you.

3 „Gefällt mir“

Thank you. I checked and everything was correct. I can’t see any call on the Dashboard page in the Usage section. Does it mean smth is wrong? Should the number of calls always be visible?

1 „Gefällt mir“

You’d need to ask embed.rocks that question. At some point I may add additional logging to the plugin which might help. You might be able to set your site to log level ‘info’ to get more information however, as there are existing calls to Rails.logger.info

1 „Gefällt mir“

Yeah, that would be great. Because now I activated the plugin and configured the settings, but youtube is not working and there is no activity on the Dashboard. I sent an email to the embed.rocks support.

1 „Gefällt mir“

Will this plugin work correctly if I store files at Amazon S3?
I still struggle with it and can’t make it working. Videos are not uploaded - only links. And there is no information on the Usage Panel of the Embed.rocks

I have a testing server. Files are stored locally on it. But the plugin also doesn’t work and there is no activity on the Usage dashboard. But videos are saved on the site.

So I can’t understand how and what to check to solve the problem.

Please, help with your ideas.

2 „Gefällt mir“