zotero / translators

Zotero Translators
http://www.zotero.org/support/dev/translators
1.19k stars 742 forks source link

YouTube: Fix missing fields when run from translation-server #3293

Closed geofferb closed 2 months ago

geofferb commented 3 months ago

Fixes #3290 by adding an extra fallback for Title, runningTime, Date, Duration, and Description fields based on a regex search for the microformat object, which can be found in the HTML regardless if the page's JS is loaded.

geofferb commented 2 months ago
  1. I think we can get all this data from page <meta> tags. Title is in <meta name="title">, description is in <meta name="description">, duration is in <meta itemprop="duration">, etc.
  2. We should not use any of these fallbacks if we aren't on the server (Zotero.isServer), because they won't change as you browse around the site and navigate to other videos in the mobile/desktop SPA.

@AbeJellinek I started with the Meta tags but switched to the microformat when I realized that the description meta tag only contained a truncated version of the description. If that's okay I'll use the Meta tags for everything.

AbeJellinek commented 2 months ago

I think it's alright if it's just on the server. Not ideal, but parsing the microformat is way messier, slower (because of the global regex search), and more prone to breakage.

AbeJellinek commented 2 months ago

Thank you!