JuanBindez / pytubefix

Python3 library for downloading YouTube Videos.
http://pytubefix.rtfd.io/
MIT License
629 stars 89 forks source link

Missing `viewCount` from payload #61

Closed Concept211 closed 6 months ago

Concept211 commented 6 months ago

When attempting to access yt.views, an error is thrown in main.py (line 453) due to viewCount being missing from the json payload (see examples below).

{'videoId': 'Jy8TRN4EZSE', 'title': 'ASSASSIN 33 AD Trailer 2020 HD', 'lengthSeconds': '119', 'channelId': 'UCqYnxos1zMk_LcKjxW_PN9A', 'isOwnerViewing': False, 'shortDescription': 'WORLD MOVIE TRAILERS \nhttps://chat.whatsapp.com/FR9qvPoWV2A4DysSoLfvhN\n\nWORLD MOVIE TRAILERS 2\nhttps://chat.whatsapp.com/KVKUf8psgrqIRlXvL2GNfu\n\nWORLD MOVIE TRAILERS 3\nhttps://chat.whatsapp.com/LKvccFOo3UH9qLoo6hLJUD\n\nWORLD MOVIE TRAILERS 4\nhttps://chat.whatsapp.com/FhhvolfptllBtdkJjUT58M', 'isCrawlable': True, 'thumbnail': {'thumbnails': [{'url': 'https://i.ytimg.com/vi/Jy8TRN4EZSE/default.jpg', 'width': 120, 'height': 90}, {'url': 'https://i.ytimg.com/vi/Jy8TRN4EZSE/mqdefault.jpg', 'width': 320, 'height': 180}, {'url': 'https://i.ytimg.com/vi/Jy8TRN4EZSE/hqdefault.jpg', 'width': 480, 'height': 360}]}, 'allowRatings': True, 'author': 'CINESHOWS', 'isPrivate': False, 'isUnpluggedCorpus': False, 'isLiveContent': False}

{'videoId': '5h_gJlPmtrI', 'title': 'Tom MacDonald - "The Machine"', 'lengthSeconds': '200', 'keywords': ['Tom MacDonald', 'Tom MacDonald Facts', 'Ben Shapiro Facts', 'Tom MacDonald Ben Shapiro', 'Eminem', 'Tom MacDonald The System', 'Conservative Rapper', 'Right Wing Rapper', 'tom macdonald the system', 'the system', 'the machine', 'the machine tom macdonald', 'the system tom macdonald', 'machine', 'political machine', 'tom macdonald machine', 'ben shapiro', 'ben shapiro facts', 'tom macdonald ben shapiro', 'the machine lyrics', 'tom macdonald new song', 'the machine rap', 'the machine song', 'tom macdonald the machine'], 'channelId': 'UCElGBUWDCa05jRzc2PfmGqQ', 'isOwnerViewing': False, 'shortDescription': 'DOWNLOAD on iTunes: https://geo.itunes.apple.com/us/album/the-machine-single/1732046415?ls=1&app=itunes\nDOWNLOAD on Amazon: https://www.amazon.com/dp/B0CW213ZNV/ref=mp_s_a_1_4?crid=7CXH8UV1D53W&dib=eyJ2IjoiMSJ9.8ZkOYS2Rh_Q05036Pa-YzZFFG0lrM_P_GHdNpuHauyxWBWSH63z0QOMqxSmd4KL5UuljWoRjzNtbJHNl8aEgoCuiNja9lAoKaeQWSIlFRoML_-f-UzCclBqvNSsxEkC26eX4XiQ1Ku_Ocom8GSmVlvwA178ujgTRmeGSwo_KhbSMg7hCgYKdH4abqpXmBIMbE6qiT3r6InhImvtL7m0oyQ.TcojcM8h2jw-rvM3zdk1kkcmb9pR5vophv8LVcmOXXw&dib_tag=se&keywords=tom+macdonald+the+machine&marketplaceId=ATVPDKIKX0DER&musicTerritory=US&qid=1708665832&sprefix=tommmacdonald+the+machine%2Caps%2C135&sr=8-4&trackAsin=B0CW213ZNV\nALBUMS & MERCH: http://www.HangOverGang.com\n\nSUBSCRIBE TO THIS CHANNEL &  CONNECT W/ TOM MACDONALD!\nFACEBOOK: http://www.facebook.com/TomMacDonaldOfficial\nINSTAGRAM: http://www.instagram.com/hangovergang\nTWITTER: http://www.twitter.com/IAmTomMacDonald\nWEBSITE: http://www.hangovergang.com\nSPOTIFY: http://spoti.fi/2H35BQR\niTUNES: https://apple.co/2BQucZO\n\nWRITTEN BY Tom MacDonald\nBEAT PRODUCED BY Tom MacDonald\n\nSHOT & DIRECTED by Nova Rockafeller \nhttp://www.instagram.com/NovaRockafeller\n\nVISUAL FX by Jared Potter\n\nMIXED & MASTERED by Evan Morgan \nhttp://www.evanmorganproductions.com \nhttp://www.youtube.com/user/emorganproductions\nhttp://www.instagram.com/EMorganProductions', 'isCrawlable': True, 'thumbnail': {'thumbnails': [{'url': 'https://i.ytimg.com/vi/5h_gJlPmtrI/default.jpg', 'width': 120, 'height': 90}, {'url': 'https://i.ytimg.com/vi/5h_gJlPmtrI/mqdefault.jpg', 'width': 320, 'height': 180}, {'url': 'https://i.ytimg.com/vi/5h_gJlPmtrI/hqdefault.jpg', 'width': 480, 'height': 360}, {'url': 'https://i.ytimg.com/vi/5h_gJlPmtrI/sddefault.jpg', 'width': 640, 'height': 480}]}, 'allowRatings': True, 'author': 'Tom MacDonald', 'isPrivate': False, 'isUnpluggedCorpus': False, 'isLiveContent': False}
JuanBindez commented 6 months ago

Without more information we can't help, pass the pytubefix version information, show a test code

iCodexDev commented 6 months ago

His right, yt.views didn't exist on yt = YouTube(self.URL) on pytubefix but in pytube it's Ok and show the count of views for video.

JuanBindez commented 6 months ago

His right, yt.views didn't exist on yt = YouTube(self.URL) on pytubefix but in pytube it's Ok and show the count of views for video.

just use pytube then