Gathering detailed insights and metrics for opex-yt-id
Gathering detailed insights and metrics for opex-yt-id
Gathering detailed insights and metrics for opex-yt-id
Gathering detailed insights and metrics for opex-yt-id
npm install opex-yt-id
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
No dependencies detected.
A robust Node.js library (ESM) to extract YouTube Video, Channel (UC-prefixed), and Playlist (PL-prefixed) IDs from a wide variety of URL formats.
youtube.com
URLs (/watch
, /v/
, /embed/
, /shorts/
, /live/
, etc.)m.youtube.com
URLs.youtu.be
and alternative y2u.be
.youtube-nocookie.com
embeds.music.youtube.com
and kids.youtube.com
.i.ytimg.com
./e/
, /vi/
, user channel fragments #p/u/...
).<iframe>
embed code strings./watch?v={ID}
on any domain.youtube.com/channel/UC...
URLs./c/Name
), legacy usernames (/user/Name
), or handles (/@Handle
) as this requires external lookups.youtube.com/playlist?list=PL...
URLs./watch?v=...&list=PL...
).music.youtube.com/playlist?list=PL...
.youtube://
mobile app schemes (common video patterns).1npm install opex-yt-id 2# or 3yarn add opex-yt-id
1import { 2 getYouTubeVideoId, 3 getYouTubeChannelId, 4 getYouTubePlaylistId 5} from 'opex-yt-id'; 6 7// Video Examples 8const urlV1 = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'; 9const urlV2 = 'https://youtu.be/jNQXAC9IVRw?t=15'; 10const urlV3 = '<iframe src="https://www.youtube-nocookie.com/embed/abcdefghijk"></iframe>'; 11const urlV4 = 'https://yewtu.be/watch?v=lmnopqrs_tu'; // Invidious example 12const urlV5 = 'https://some-random-proxy.net/watch?v=123456789_A'; // Generic fallback 13const urlV6 = 'not a valid url string'; 14 15console.log("Video IDs:"); 16console.log(getYouTubeVideoId(urlV1)); // Output: dQw4w9WgXcQ 17console.log(getYouTubeVideoId(urlV2)); // Output: jNQXAC9IVRw 18console.log(getYouTubeVideoId(urlV3)); // Output: abcdefghijk 19console.log(getYouTubeVideoId(urlV4)); // Output: lmnopqrs_tu 20console.log(getYouTubeVideoId(urlV5)); // Output: 123456789_A 21console.log(getYouTubeVideoId(urlV6)); // Output: null 22console.log(getYouTubeVideoId(null)); // Output: null 23 24// Channel Examples 25const urlC1 = 'https://www.youtube.com/channel/UCBR8-60-B28hp2BmDPdntcQ'; 26const urlC2 = 'https://m.youtube.com/channel/UC_Channel_ID_Chars'; 27const urlC3 = 'https://youtube.com/c/SomeCustomName'; // Will return null 28const urlC4 = 'https://www.youtube.com/@handle'; // Will return null 29const urlC5 = 'https://vid.puffyan.us/channel/UCBR8-60-B28hp2BmDPdntcQ'; // 3rd party 30 31console.log("\nChannel IDs (UC-prefixed only):"); 32console.log(getYouTubeChannelId(urlC1)); // Output: UCBR8-60-B28hp2BmDPdntcQ 33console.log(getYouTubeChannelId(urlC2)); // Output: UC_Channel_ID_Chars 34console.log(getYouTubeChannelId(urlC3)); // Output: null (custom URL not resolved) 35console.log(getYouTubeChannelId(urlC4)); // Output: null (handle not resolved) 36console.log(getYouTubeChannelId(urlC5)); // Output: UCBR8-60-B28hp2BmDPdntcQ 37 38// Playlist Examples 39const urlP1 = 'https://www.youtube.com/playlist?list=PLBCF2DAC6FFB574DE'; 40const urlP2 = 'https://www.youtube.com/watch?v=VIDEOID&list=PLIivdWyY5sqL9mXChOLu_U4Q431r9fIGN&index=2'; 41const urlP3 = 'https://music.youtube.com/playlist?list=PL_Playlist_ID_Chars'; 42 43console.log("\nPlaylist IDs (PL-prefixed only):"); 44console.log(getYouTubePlaylistId(urlP1)); // Output: PLBCF2DAC6FFB574DE 45console.log(getYouTubePlaylistId(urlP2)); // Output: PLIivdWyY5sqL9mXChOLu_U4Q431r9fIGN 46console.log(getYouTubePlaylistId(urlP3)); // Output: PL_Playlist_ID_Chars
getYouTubeVideoId(urlString)
urlString
: string | null | undefined
- The URL or string potentially containing a YouTube video link or ID.string | null
- The 11-character YouTube Video ID if found and valid, otherwise null
.getYouTubeChannelId(urlString)
urlString
: string | null | undefined
- The URL or string potentially containing a YouTube channel link.string | null
- The 24-character YouTube Channel ID (starting with UC
) if found and valid, otherwise null
./c/
), legacy usernames (/user/
), or handles (/@/
).getYouTubePlaylistId(urlString)
urlString
: string | null | undefined
- The URL or string potentially containing a YouTube playlist link.string | null
- The YouTube Playlist ID (starting with PL
) if found and valid, otherwise null
.MIT
Надежная Node.js библиотека (ESM) для извлечения ID Видео, Каналов (с префиксом UC) и Плейлистов (с префиксом PL) YouTube из множества различных форматов URL.
youtube.com
(/watch
, /v/
, /embed/
, /shorts/
, /live/
и т.д.)m.youtube.com
.youtu.be
и альтернативный y2u.be
.youtube-nocookie.com
с повышенной приватностью.music.youtube.com
и kids.youtube.com
.i.ytimg.com
./e/
, /vi/
, фрагменты каналов пользователей #p/u/...
).<iframe>
./watch?v={ID}
на любом домене.youtube.com/channel/UC...
./c/Имя
), устаревшие имена пользователей (/user/Имя
) или дескрипторы (/@Дескриптор
), так как это требует внешних запросов.youtube.com/playlist?list=PL...
./watch?v=...&list=PL...
).music.youtube.com/playlist?list=PL...
.youtube://
(распространенные шаблоны для видео).1npm install opex-yt-id 2# или 3yarn add opex-yt-id
1import { 2 getYouTubeVideoId, 3 getYouTubeChannelId, 4 getYouTubePlaylistId 5} from 'opex-yt-id'; 6 7// Примеры для Видео 8const urlV1 = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'; 9const urlV2 = 'https://youtu.be/jNQXAC9IVRw?t=15'; 10const urlV3 = '<iframe src="https://www.youtube-nocookie.com/embed/abcdefghijk"></iframe>'; 11const urlV4 = 'https://yewtu.be/watch?v=lmnopqrs_tu'; // Пример Invidious 12const urlV5 = 'https://some-random-proxy.net/watch?v=123456789_A'; // Общий запасной вариант 13const urlV6 = 'невалидная строка url'; 14 15console.log("ID Видео:"); 16console.log(getYouTubeVideoId(urlV1)); // Вывод: dQw4w9WgXcQ 17console.log(getYouTubeVideoId(urlV2)); // Вывод: jNQXAC9IVRw 18console.log(getYouTubeVideoId(urlV3)); // Вывод: abcdefghijk 19console.log(getYouTubeVideoId(urlV4)); // Вывод: lmnopqrs_tu 20console.log(getYouTubeVideoId(urlV5)); // Вывод: 123456789_A 21console.log(getYouTubeVideoId(urlV6)); // Вывод: null 22console.log(getYouTubeVideoId(null)); // Вывод: null 23 24// Примеры для Каналов 25const urlC1 = 'https://www.youtube.com/channel/UCBR8-60-B28hp2BmDPdntcQ'; 26const urlC2 = 'https://m.youtube.com/channel/UC_Channel_ID_Chars'; 27const urlC3 = 'https://youtube.com/c/SomeCustomName'; // Вернет null 28const urlC4 = 'https://www.youtube.com/@handle'; // Вернет null 29const urlC5 = 'https://vid.puffyan.us/channel/UCBR8-60-B28hp2BmDPdntcQ'; // Сторонний фронтенд 30 31console.log("\nID Каналов (только с префиксом UC):"); 32console.log(getYouTubeChannelId(urlC1)); // Вывод: UCBR8-60-B28hp2BmDPdntcQ 33console.log(getYouTubeChannelId(urlC2)); // Вывод: UC_Channel_ID_Chars 34console.log(getYouTubeChannelId(urlC3)); // Вывод: null (пользовательский URL не распознан) 35console.log(getYouTubeChannelId(urlC4)); // Вывод: null (дескриптор не распознан) 36console.log(getYouTubeChannelId(urlC5)); // Вывод: UCBR8-60-B28hp2BmDPdntcQ 37 38// Примеры для Плейлистов 39const urlP1 = 'https://www.youtube.com/playlist?list=PLBCF2DAC6FFB574DE'; 40const urlP2 = 'https://www.youtube.com/watch?v=VIDEOID&list=PLIivdWyY5sqL9mXChOLu_U4Q431r9fIGN&index=2'; 41const urlP3 = 'https://music.youtube.com/playlist?list=PL_Playlist_ID_Chars'; 42 43console.log("\nID Плейлистов (только с префиксом PL):"); 44console.log(getYouTubePlaylistId(urlP1)); // Вывод: PLBCF2DAC6FFB574DE 45console.log(getYouTubePlaylistId(urlP2)); // Вывод: PLIivdWyY5sqL9mXChOLu_U4Q431r9fIGN 46console.log(getYouTubePlaylistId(urlP3)); // Вывод: PL_Playlist_ID_Chars
getYouTubeVideoId(urlString)
urlString
: string | null | undefined
- URL или строка, потенциально содержащая ссылку или ID видео YouTube.string | null
- 11-значный ID видео YouTube, если найден и действителен, иначе null
.getYouTubeChannelId(urlString)
urlString
: string | null | undefined
- URL или строка, потенциально содержащая ссылку на канал YouTube.string | null
- 24-значный ID канала YouTube (начинающийся с UC
), если найден и действителен, иначе null
./c/
), устаревшие имена пользователей (/user/
) или дескрипторы (/@/
).getYouTubePlaylistId(urlString)
urlString
: string | null | undefined
- URL или строка, потенциально содержащая ссылку на плейлист YouTube.string | null
- ID плейлиста YouTube (начинающийся с PL
), если найден и действителен, иначе null
.MIT
No vulnerabilities found.
No security vulnerabilities found.