Parafia Skoczów
  • 👋Witaj w Parafii Skoczów
  • O APLIKACJI
    • ✨Funkcjonalności
    • 📷Galeria
    • 🛠️Zarządzanie treściami
  • DLA PROGRAMISTÓW
    • 🏗️Przegląd narzędzi
    • ⛪Parafia Skoczów
      • Assets
      • Components
        • Atoms
        • Molecules
        • Organisms
        • Templates
      • Helpers
        • getAnimationProps
        • getData
        • getTransmissionUrl
        • searchContent
        • useModal
      • Hooks
        • useDisablePinchZoom
        • usePinching
        • useSwipe
      • Providers
        • ContentProvider
        • FirebaseProvider
        • PlaylistProvider
      • Utils
      • Views
        • Home
        • Categories
        • Titles
        • Text
        • Playlist
        • Search
      • Cordova
      • Rozwiązywanie problemów
    • 🎶Playlist Maker
      • Assets
      • Components
        • Atoms
        • Molecules
        • Organisms
        • Templates
      • Helpers
      • Hooks
        • useDnd
        • useEdit
        • useName
        • useModal
      • Providers
        • ContentProvider
        • FirebaseProvider
        • NotificationProvider
        • PlaylistProvider
      • Utils
      • Cordova
      • Rozwiązywanie problemów
Powered by GitBook
On this page
  1. DLA PROGRAMISTÓW
  2. Parafia Skoczów
  3. Helpers

getTransmissionUrl

Pobiera i zwraca adres URL najnowszego filmu z kanału Parafii Skoczów, umożliwiając dostęp do transmisji online.

getTransmissionUrl.js
import axios from 'axios';

export const getLatestVideoUrl = async () => {
  const channelId = 'UCnKWrqGFWFbwGC6LhBcK8GA';
  const apiKey = process.env.REACT_APP_YOUTUBE_API_KEY;
  const youtubeApiBaseUrl = 'https://www.googleapis.com/youtube/v3';

  const playlist = await axios.get(`${youtubeApiBaseUrl}/channels`, {
    params: {
      part: 'contentDetails',
      id: channelId,
      key: apiKey,
    },
  });
  const playlistId = playlist.data.items[0].contentDetails.relatedPlaylists.uploads;

  const latestVideo = await axios.get(`${youtubeApiBaseUrl}/playlistItems`, {
    params: {
      part: 'snippet',
      playlistId: playlistId,
      maxResults: 1,
      order: 'date',
      key: apiKey,
    },
  });
  const videoId = latestVideo.data.items[0].snippet.resourceId.videoId;
  const videoUrl = `https://www.youtube.com/watch?v=${videoId}`;

  return videoUrl;
};
PreviousgetDataNextsearchContent

Last updated 1 year ago

⛪