imputnet / cobalt

best way to save what you love
https://cobalt.tools
GNU Affero General Public License v3.0
17.29k stars 1.41k forks source link

YouTube Token Works Independently but Fails After Configuring in Docker (error.api.youtube.login) #898

Closed wenguan0927 closed 1 week ago

wenguan0927 commented 2 weeks ago

problem description

I have successfully verified that the YouTube token parameters work independently and can retrieve YouTube Channel data without any issues. However, after configuring the token parameters in cookies.json and uncomment cookies.json setting in codocker-compose.yml, and restarting the Docker application, any request for YouTube video conversion returns the following error: error.api.youtube.login.

your instance configuration

docker-compose.yml config is blow

services:
    cobalt-api:
        image: ghcr.io/imputnet/cobalt:10

        init: true
        read_only: true
        restart: unless-stopped
        container_name: cobalt-api

        ports:
            #- 9000:9000/tcp
            # if you use a reverse proxy (such as nginx),
            # uncomment the next line and remove the one above (9000:9000/tcp):
            - 127.0.0.1:9000:9000

        environment:
            # replace https://api.url.example/ with your instance's url
            # or else tunneling functionality won't work properly
            API_URL: "https://xxxxxxx.com/"
            # if you want to use cookies for fetching data from services,
            # uncomment the next line & volumes section
            COOKIE_PATH: "/cookies.json"

            # it's recommended to configure bot protection or api keys if the instance is public,
            # see /docs/protect-an-instance.md for more info

            # see /docs/run-an-instance.md for more variables that you can use here

        labels:
            - com.centurylinklabs.watchtower.scope=cobalt

        # uncomment only if you use the COOKIE_PATH variable
        volumes:
            - ./cookies.json:/cookies.json

    # watchtower updates the cobalt image automatically
    watchtower:
        image: ghcr.io/containrrr/watchtower
        restart: unless-stopped
        command: --cleanup --scope cobalt --interval 900 --include-restarting
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
dumbmoron commented 2 weeks ago

are you sure cookies.json are in the right location? (they should be in the same folder as where you run docker compose up -d)

also, have you followed the "how to configure an instance for youtube" tutorial?

wenguan0927 commented 1 week ago

are you sure cookies.json are in the right location? (they should be in the same folder as where you run docker compose up -d)

also, have you followed the "how to configure an instance for youtube" tutorial?

Yes, I put the 'cookies.json' in the same folder of docker-compose.yml, and restart docker instance, I test two different cookies.json token format of blow , but got the error 'error.api.fetch.critical'. The token works when I use it to request Youtube channel infomation by node.js script. { "youtube_oauth": [ "access_token=xxxxxxxxxxxxxxxx; refresh_token=xxxxxxxxxxxxxxxxxxx; scope=https://www.googleapis.com/auth/youtube.readonly; token_type=Bearer; expiry_date=1731170213480" ] }

{ "youtube_oauth": [ "{\"access_token\":\"xxxxxxxxxxxxxxxxxxxxx\",\"scope\":\"https://www.googleapis.com/auth/youtube.readonly\",\"token_type\":\"Bearer\",\"expiry_date\":1731168717606,\"refresh_token\":\"xxxxxxxxxxxxxxxxxxx"}" ] }

wukko commented 1 week ago

does cobalt print a message in docker logs that cookies are loaded?

wenguan0927 commented 1 week ago

Problem is solved! first I follow the "how to configure an instance for youtube" tutorial, but got timeout exception even if I use VPN to visit internet of USA, then I use another way by search in google to generate token, but it's not works. finally I seek help of a friend in USA to generate token follow the tutorial, after got the token and replace, it's works! If follow "how to configure an instance for youtube" tutorial step 4, it can be time out in China region even if you use VPN.