YouTube Structured Transcript Extractor avatar

YouTube Structured Transcript Extractor

Try for free

1 day trial then $15.00/month - No credit card required now

View all Actors
YouTube Structured Transcript Extractor

YouTube Structured Transcript Extractor

karamelo/youtube-structured-transcript-extractor
Try for free

1 day trial then $15.00/month - No credit card required now

Extract 1 or 1000s of YouTube transcripts fast. Save time & effort . Get accurate structured transcripts or captions in seconds for each video. Export in various formats,, JSON, XML, HTML, CSV, EXCEL... Boost your productivity!

ED

Export as string

Closed

edvin opened this issue
4 months ago

Hey, I am trying to modify the output to put only the TEXT as string. I tried to tinker with code but can not make it trim, truncate and concatenate the response into one string. Can you maybe include export-as-string? I use API to send request for it and then return back with the transcript. It appears correctly on apify and works GREAT, just can not use it as a string. My code:

const fetch = require('node-fetch');

const apiUrl = 'https://api.apify.com/v2/acts/karamelo~youtube-structured-transcript-extractor/run-sync-get-dataset-items?token=apify_api_MyTokenWasHereButIDeletedIt';

// Split the input URLs by comma and trim any whitespace const urls = $urls.split(',').map(url => url.trim());

const input = { urls: urls };

const options = { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(input) };

async function fetchTranscripts() { try { const response = await fetch(apiUrl, options); if (!response.ok) { throw new Error(Error fetching data from Apify: ${response.statusText}); } const result = await response.json(); console.log('Result from Apify:', result);

1if (!result || !result.items || !Array.isArray(result.items)) {
2  throw new Error('Invalid response format from Apify');
3}
4
5// Extract and concatenate the transcript text
6const transcript = result.items.map(item => {
7  const key = Object.keys(item)[0];
8  return item[key];
9}).join(' ').trim();

... [trimmed]

karamelo avatar

Hi there, Thanks for the advice. I will add support for TEXT API and stringify the output as soon as possible. the issue imo is the line breaks. I will notify you here when done.

ED

edvin

4 months ago

WOW, so quick! I am in love, can not wait, as I am a no-code person stuck with AI trying to rewrite code to no avail :)

karamelo avatar

hi edvin here is an example output, I used your code, please tell me how you want it to be formatted: Result from Apify: [ { 'videoId: dQw4w9WgXcQ \ntitle: Rick Astley - Never Gonna Give You Up (Official Music Video)': '[Music]', 'videoId: jNQXAC9IVRw \ntitle: Me at the zoo': 'All right, so here we are, in front of the elephants' }, { 'videoId: dQw4w9WgXcQ \ntitle: Rick Astley - Never Gonna Give You Up (Official Music Video)': "we're no strangers to", 'videoId: jNQXAC9IVRw \ntitle: Me at the zoo': 'the cool thing about these guys is that they have really...' }, { 'videoId: dQw4w9WgXcQ \ntitle: Rick Astley - Never Gonna Give You Up (Official Music Video)': 'love you know the rules and so do',
'videoId: jNQXAC9IVRw \ntitle: Me at the zoo': 'really really long trunks' }, { 'videoId: dQw4w9WgXcQ \ntitle: Rick Astley - Never Gonna Give You Up (Official Music Video)': "I I full commitments while I'm thinking", 'videoId: jNQXAC9IVRw \ntitle: Me at the zoo': "and that's cool" } ]

karamelo avatar

Here is a test API endpoint and tell me if its ok, i will create a new actor for api use, try this code and tell me if its ok:

ED

edvin

4 months ago

2024-08-03 22:29:33 [INFO]: [server]: Chatflow 93c69a0a-c0e7-4c80-a0cf-88d8044bceb9 added into ChatflowPool error Error fetching data from Apify error Error fetching data from Apify: Error: Error fetching data from Apify: Forbidden info at fetchTranscripts (/usr/src/packages/components/dist/nodes/tools/CustomTool:21:13) info at process.processTicksAndRejections (node:internal/process/task_queues:95:5) info at async /usr/src/packages/components/dist/nodes/tools/CustomTool:51:13 error Error fetching data from Apify: Error: Error fetching data from Apify: Forbidden info at fetchTranscripts (/usr/src/packages/components/dist/nodes/tools/CustomTool:21:13) info at process.processTicksAndRejections (node:internal/process/task_queues:95:5) error Error fetching data from Apify info at async /usr/src/packages/components/dist/nodes/tools/CustomTool:51:13

karamelo avatar

Hi edvin, here is a working code, I modified your code and commented the line ".map(segment => segment.text)" because the "const text" is already a string, you can use the test actor API endpoint in the attached file, its free with platform usage until I fix the results format of the YouTube Structured Transcript Extractor. By the way the YouTube Structured Transcript Extractor pricing will become a "rental model" starting the 5 august i think. If you have any questions please contact me here

Developer
Maintained by Community

Actor Metrics

  • 16 monthly users

  • 8 stars

  • >99% runs succeeded

  • Created in Jun 2024

  • Modified 8 hours ago