GithubHelp home page GithubHelp logo

mendable_scraper's Introduction

Mendable Scraper Suite

This repository contains utilities to fetch metadata from YouTube channels, fetch video transcripts, fetch transcripts from entire channel, and scrape data from YAML files (like OpenAPI specs).

Below you'll find a description of each utility and how to use them.

Table of Contents

Utilities

fetchChannelMetadata.ts

This utility is used to fetch video links from a given YouTube channel URL.

Usage:

import { fetchVideosFromChannel } from './fetchChannelMetadata';

fetchVideosFromChannel('https://www.youtube.com/@engineerprompt/videos');

fetchVideoTranscript.ts

This utility fetches the transcript of a given YouTube video link/url.

Usage:

import { youtubeVideoScraper } from './fetchVideoTranscript';

const videoURL = 'youtube.com/watch?v=wHEIT32ZEVs';
youtubeVideoScraper(videoURL).then(console.log).catch(console.error);

fetchChannelTranscripts.ts

This utility fetches transcripts from an entire YouTube channel, given its URL.

Usage:

import { fetchTranscriptsFromChannel } from './fetchChannelTranscripts';

fetchTranscriptsFromChannel('https://www.youtube.com/@Finaius').then(results => {
    // Handle results here.
}).catch(error => {
    console.error(`Failed to fetch transcripts: ${error}`);
});

fetchYamlData.ts

This utility fetches and parses YAML content, converting it into sections for further processing. It can be useful for working with OpenAPI specifications.

Usage:

import { scrapeOpenApiYaml } from './fetchYamlData';

scrapeOpenApiYaml('https://petstore.swagger.io/v2/swagger.yaml').then(sections => {
    console.log(JSON.stringify(sections, null, 2));
});

Tests

Prerequisites

Ensure you have jest installed globally or locally within the project:

npm install jest --save-dev

Running the Tests

Running All Tests:

npm test

Running Individual Tests:

For fetchVideoTranscript.test.ts:

npx jest fetchVideoTranscript.test.ts

For fetchYamlData.test.ts:

npx jest fetchYamlData.test.ts

Test Suites

  1. fetchVideoTranscript.test.ts

    • YouTube URL Validity: Checks if different URL formats (http, https, regular, short) are recognized as valid YouTube URLs.
    • Transcript Fetching: Verifies that valid YouTube URLs return a proper formatted response when fetching transcripts.
    • Error Handling: Ensures that errors during transcript fetching, whether from the YouTube Transcript service or elsewhere, are correctly handled and appropriate error messages are relayed.
  2. fetchYamlData.test.ts

    • Fetching with Retry: Validates data fetching retries on failures and can either succeed or fail after a set number of retries.
    • YAML Parsing: Ensures valid YAML data is correctly parsed into sections and errors like a 404 response result in appropriate outcomes.

mendable_scraper's People

Contributors

bernard-rr avatar

Watchers

Nicolas avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.