Advertisement
Guest User

Youtube Endscreen Setter

a guest
Dec 5th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { init, getVideo, getEndScreen, setEndScreen, endScreen } = require('youtube-studio');
  2. const {
  3.     SID,
  4.     HSID,
  5.     SSID,
  6.     APISID,
  7.     SAPISID,
  8. } = require('./cookies')
  9.  
  10. const VIDEO_ID = 'V91KGSHbmDs'
  11. const CHANNEL_ID = 'UCM5rDUGQR9E2I8Y466m6RCg'
  12.  
  13.  
  14. const initialize = async () => {
  15.     return init({
  16.         SID,
  17.         HSID,
  18.         SSID,
  19.         APISID,
  20.         SAPISID
  21.     }).then(() => {
  22.         console.log("Connected!")
  23.     })
  24. }
  25.  
  26.  
  27. initialize().then(async () => {
  28.     // Get Video Endscreen (works well)
  29.     // const endScreen = await getEndScreen(VIDEO_ID)
  30.     // console.log(endScreen.endscreens)
  31.     // console.log(endScreen.endscreens[0].elements)
  32.  
  33.  
  34.     // Set Video Endscreen
  35.     const videoLengthSec = 682
  36.     const TWENTY_SEC_BEFORE_END_MS = (videoLengthSec - 20) * 1000
  37.  
  38.    
  39.     const result = await setEndScreen(VIDEO_ID, TWENTY_SEC_BEFORE_END_MS, [
  40.         { ...endScreen.TYPE_RECENT_UPLOAD }, // recent upload in top left position
  41.         { ...endScreen.POSITION_BOTTOM_RIGHT, ...endScreen.TYPE_SUBSCRIBE(CHANNEL_ID) }, // subscribe button
  42.         { ...endScreen.POSITION_TOP_RIGHT,    ...endScreen.TYPE_BEST_FOR_VIEWERS,      ...endScreen.DELAY(500) }, // best for viewers delayed with 0.5 sec
  43.     ]).catch((err) => {
  44.         console.log(err)
  45.     })
  46.        
  47.     console.log(JSON.stringify(result, null, 4))
  48. })
  49.  
  50.  
  51.  
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement