gatecrasher777 / ytcog

YouTube innertube class library for node-js; session, searches, channels, playlist, videos, comments and downloads.
MIT License
74 stars 14 forks source link

403 error on most video downloads #65

Open AlexanderBooth84 opened 1 week ago

AlexanderBooth84 commented 1 week ago

I'm trying to download 1080p videos using the latest release but it seems to silently fail falling back to the 360p version no matter what settings I use.

Using the video_test.js example with no config changes but adding some console logging to the failed function in dl.js I'm seeing:

dl: failed - vformat=0, aformat=0 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=0, aformat=1 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=0, aformat=2 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=0, aformat=3 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=0, aformat=4 { msg: { msg: 'failed', fail: 'video', reason: 403 } }
dl: failed - vformat=1, aformat=0 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=1, aformat=1 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=1, aformat=2 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=1, aformat=3 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=1, aformat=4 { msg: { msg: 'failed', fail: 'video', reason: 403 } }
dl: failed - vformat=2, aformat=0 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=2, aformat=1 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=2, aformat=2 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=2, aformat=3 { msg: { msg: 'failed', fail: 'audio', reason: 403 } }
dl: failed - vformat=2, aformat=4 { msg: { msg: 'failed', fail: 'video', reason: 403 } }

I can't see how the recent changes would cause this so perhaps something has changed at the YT end?

gatecrasher777 commented 4 days ago

Hi. Yes, another barrier from Youtube. There is a work around to this by spoofing an alternative client to the standard web client. I will push a PR soon.

gatecrasher777 commented 4 days ago

PR #66 published. Worked when testing. Let me know if it helps.

AlexanderBooth84 commented 3 days ago

The video downloads seem to work ok but only if you use a cookie and user-agent.

However the search functionality seems to be broken.

You can see this with the example application that yields the following.

node examples/search_test.js 
Session status: OK ()

Search for 100 videos with query: "soccer"
TypeError: Cannot read properties of undefined (reading 'twoColumnSearchResultsRenderer')
    at Search.fetch (/Users/russt/dev/src/zerolabs/gizmos/src/modules/ytcog/node_modules/ytcog/lib/search.js:290:36)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runVideos (/Users/russt/dev/src/zerolabs/gizmos/src/modules/ytcog/node_modules/ytcog/examples/search_test.js:42:2)
    at async run (/Users/russt/dev/src/zerolabs/gizmos/src/modules/ytcog/node_modules/ytcog/examples/search_test.js:107:3)
Raw search json saved to ./examples/searchVideos.json

Search status: OK (No results)
Found 0 videos for "soccer"

Search info/videos saved to ./examples/search_videos.json

Search for 30 playlists
TypeError: Cannot read properties of undefined (reading 'twoColumnSearchResultsRenderer')
    at Search.fetch (/Users/russt/dev/src/zerolabs/gizmos/src/modules/ytcog/node_modules/ytcog/lib/search.js:290:36)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runPlaylists (/Users/russt/dev/src/zerolabs/gizmos/src/modules/ytcog/node_modules/ytcog/examples/search_test.js:62:2)
    at async run (/Users/russt/dev/src/zerolabs/gizmos/src/modules/ytcog/node_modules/ytcog/examples/search_test.js:108:3)
Raw search json saved to ./examples/searchPlaylists.json

Search status: OK (No results)
Found 0 results for "soccer"

Search info/results saved to ./examples/search_playlists.json

Search for 50 channels
TypeError: Cannot read properties of undefined (reading 'twoColumnSearchResultsRenderer')
    at Search.fetch (/Users/russt/dev/src/zerolabs/gizmos/src/modules/ytcog/node_modules/ytcog/lib/search.js:290:36)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runChannels (/Users/russt/dev/src/zerolabs/gizmos/src/modules/ytcog/node_modules/ytcog/examples/search_test.js:82:2)
    at async run (/Users/russt/dev/src/zerolabs/gizmos/src/modules/ytcog/node_modules/ytcog/examples/search_test.js:109:3)
Raw search json saved to ./examples/searchChannels.json

Search status: OK (No results)
Found 0 channels for "soccer"

Search info/channels saved to ./examples/search_channels.json
Session complete.
gatecrasher777 commented 2 days ago

Around the end of last month, Youtube started making it increasingly necessary to have a logged-in cookie to access video info. It is not a problem unique to ytcog.

As for search, there are quite a lot of similar problems in this project that I will patch shortly in v2.6

In the meantime, I am working on a new innertube project that will eventually replace this project.

AlexanderBooth84 commented 10 hours ago

Thanks for the update. Your efforts are much appreciated. Great project.