Skip to content

YouTube Support #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Zibbp opened this issue Jun 27, 2022 · 4 comments
Open

YouTube Support #16

Zibbp opened this issue Jun 27, 2022 · 4 comments
Labels

Comments

@Zibbp
Copy link
Owner

Zibbp commented Jun 27, 2022

YouTube VOD and live support

Video
Both VOD and live video is easy. Use streamlink for live streams and yt-dlp for vods.

Chat
Chat will be the problem. Yt-dlp supports vod chat downloading. Chat-downloader supports live chat downloading. The problem is emote support. TwitchDownloader which is used to render the chat does not support any YouTube functionality.

@Zibbp Zibbp added the future label Jun 27, 2022
@lpuv
Copy link

lpuv commented Feb 6, 2023

Would it be possible to implement this without chat support/emote support for now?

@Zibbp
Copy link
Owner Author

Zibbp commented Feb 6, 2023

Hi,
No plans to add any form of YouTube support in the near future. In the meantime you can manually download a YouTube stream/video using yt-dlp and manually import it into Ganymede in the UI or by using the API.

@CappiSteijns
Copy link

I'm attempting to import a few hundred YouTube videos into Ganymede, but I lack experience with APIs. Manual importing would be very time-consuming, so I'm eager to explore this approach.

To import the videos, I believe I need to use the /api/v1/vod endpoint.

ChatGPT generated the following script for me:

python

import requests

# API URL
url = 'http://192.168.68.61:4810/api/v1/vod'  # Replace with your actual API URL

# JWT token (replace with the token you received after logging in)
jwt_token = 'your_received_jwt_token'

# Headers with accept and content-type
headers = {
    'accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': f'Bearer {jwt_token}'  # Include the JWT token in the headers
}

# Example payload; adjust as needed
payload = {
    "caption_path": "path/to/caption",
    "channel_id": "channel_id_example",
    "chat_path": "path/to/chat",
    "chat_video_path": "path/to/chat_video",
    "duration": 3600,  # Example duration in seconds
    "ext_id": "external_id_example",
    "id": "video_id_example",
    "info_path": "path/to/info",
    "platform": "twitch",
    "processing": True,
    "resolution": "1920x1080",
    "streamed_at": "2024-10-01T00:00:00Z",  # Example timestamp
    "thumbnail_path": "path/to/thumbnail",
    "title": "Video Title",
    "type": "archive",
    "video_path": "path/to/video",
    "views": 100,  # Example view count
    "web_thumbnail_path": "path/to/web_thumbnail"
}

try:
    # Send the POST request
    response = requests.post(url, headers=headers, json=payload)
    
    # Check the status code
    if response.status_code == 201:  # 201 Created
        print("VOD successfully created!")
        print("Response data:", response.json())
    else:
        print(f"Error creating VOD: {response.status_code}")
        print("Error message:", response.json())
except Exception as e:
    print("Error during the request:", e)

However, when I run this script, I receive the error message {'message': 'Invalid access token'}.

I'm unsure how to obtain a valid token. I have configured the token in the API container as follows:

markdown

  - JWT_SECRET=a47586f791000d18f61c1e7ce27dbdbe92c5bfb75de856eaf2f5309260e5c0bd
  - JWT_REFRESH_SECRET=b523e954c89926e838d869c2a641a7eafa4711155756b003f1b29fa20fa8a280

I'm starting to feel that my lack of API knowledge may make this task unrealistic. I understand that importing YouTube videos may be outside the scope of this project. If you think this is not a viable option for someone without experience, please let me know. Otherwise, I would greatly appreciate any tips on how to successfully import videos into Ganymede.

Thank you ! :)

@Zibbp
Copy link
Owner Author

Zibbp commented Oct 1, 2024

Authentication only supports cookies so you'll either need to use the cookie in your browser or perform an auth request in your python script.

POST http://ip:port/api/v1/auth/login

with the following body

{
  "username": "my_username",
  "password": "my_password"
}

Then you need to use the cookie returned by the response (access-token) for any future requests. Not sure how to do this in Python, but probably easy with requests.

For the request body for creating a VOD it looks like you have it mostly right. I would reference the http/vod.go CreateVodRequest struct for details of what is required.

It may also be useful to perform a GET /api/v1/vod to see what fields are populated for your current vods.

Let me know if there's anything else I can help with. I don't like to advertise the API much as I tend to change it between versions.

Related, are you downloading chats for your YouTube vods or just the video/stream?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Future
Development

No branches or pull requests

3 participants