Bulk gathering of metadata from youtube videos

Hi! I came across a thread that helped me get multiple URLs added to Zotero instead of manually adding them. I only need a .txt with URLs and open the Javascript option in Zotero.

Here's the code I'm talking about:

var path = 'C:\\Users\\Tet\\Documents\\urls.txt';
var urls = Zotero.File.getContents(path).split('\n').map(url => url);
await Zotero.HTTP.processDocuments(
urls,
async function (doc) {
var translate = new Zotero.Translate.Web();
translate.setDocument(doc);
var translators = await translate.getTranslators();
if (translators.length) {
translate.setTranslator(translators[0]);
try {
await translate.translate();
return;
}
catch (e) {}
}
await ZoteroPane.addItemFromDocument(doc);
}
)

However, it is not working for my purposes. One, I don't get to choose where the citations are saved. Second, I get very generic metadata; Since the urls are youtube videos, I want that metadata described when I'm exporting it, instead of calling it a webpage. Is it possible to still get the metadata from the pages I'm extracting metadata, or it's outside the scope of Zotero?

Thanks!
  • Did you try importing the same URL using the Zotero browser connector? There's a good chance that YouTube pages simply work better when accessed through the browser given the way they're constructed.
  • @adamsmith I'm trying to get multiple entries of youtube videos into Zotero by running the code I mentioned earlier. This way, I can add multiple entries faster than manually importing the URLs using the Zotero browser connector. The channel I want to import metadata from has more than a hundred videos, and I would like to automate the process.
  • I understand what you're trying to do, but you'll want to figure out why you're not getting decent import quality.
    If the URLs also don't work in the browser, there might be something we can do. If they work when using the browser connector but don't work from the bulk script, you're likely out of luck.
  • >If they work when using the browser connector but don't work from the bulk script, you're likely out of luck.

    They do work with the browser connector, but not when I'm trying to use the code I mentioned. Maybe I'm out of luck indeed.
  • You'd need to use loadDocuments(), which uses a hidden browser, not processDocuments(), which just fetches the raw HTML. See the warnings and discussion in the other thread about using that.
Sign In or Register to comment.