offish / twitchtube

Twitch YouTube bot. Automatically make video compilations of the most viewed Twitch clips and upload them to YouTube using Python 3.
MIT License
538 stars 77 forks source link

NameError: name 'data' is not defined, Python 3.7, 3.8 #2

Closed lxgameshow closed 4 years ago

lxgameshow commented 4 years ago

I downloaded all from requirements.txt. when i run main.py, i get error. How fix this? twitchtube | 15:55:50 - info: Starting to make a video for Team Fortress 2 Traceback (most recent call last): File "C:\twitchtube-master2\main.py", line 29, in <module> names = download_clips(clips, VIDEO_LENGTH, path) File "C:\twitchtube-master2\dist\clips.py", line 97, in download_clips download_clip(data[clip]["url"], path) File "C:\twitchtube-master2\dist\clips.py", line 36, in download_clip mp4_url, clip_title = get_clip_data(slug) File "C:\twitchtube-master2\dist\clips.py", line 14, in get_clip_data thumb_url = clip_info['data'][0]['thumbnail_url'] KeyError: 'data'

offish commented 4 years ago

I will take a look at this and see if I can find the issue.

offish commented 4 years ago

You've ran into this issue because Twitch recently changed the Helix API endpoint to require OAuth authentication. I might fix this in the future. https://discuss.dev.twitch.tv/t/requiring-oauth-for-helix-twitch-api-endpoints/23916

lxgameshow commented 4 years ago

I got it, fix this please ;) I will be waiting. P.S i am new in programming, so i cant help you, but your script is AMAZING! Keep going =)

epsilon573 commented 4 years ago

Ok , I have fixed it.

Replace thumb_url = clip_info['data'][0]['thumbnail_url'] with thumb_url = clip_info['thumbnails']['medium']

You may also need to replace a few more things. Just request a clip JSON file from twitch and change accordingly. Also, I am using an authentication token, Not sure if you need it too.

lxgameshow commented 4 years ago

Ok , I have fixed it.

Replace thumb_url = clip_info['data'][0]['thumbnail_url'] with thumb_url = clip_info['thumbnails']['medium']

You may also need to replace a few more things. Just request a clip JSON file from twitch and change accordingly. Also, I am using an authentication token, Not sure if you need it too.

Fixed, sends me error key

twitchtube | 01:13:05 - info: Starting to make a video for Rust Traceback (most recent call last): File "C:\twitch\twitchtube-master2\main.py", line 29, in <module> names = download_clips(clips, VIDEO_LENGTH, path) File "C:\twitch\twitchtube-master2\dist\clips.py", line 97, in download_clips download_clip(data[clip]["url"], path) File "C:\twitch\twitchtube-master2\dist\clips.py", line 36, in download_clip mp4_url, clip_title = get_clip_data(slug) File "C:\twitch\twitchtube-master2\dist\clips.py", line 14, in get_clip_data thumb_url = clip_info['thumbnails']['medium'] KeyError: 'thumbnails'

epsilon573 commented 4 years ago

I recommend using python-twitch client and writing your own script.

lxgameshow commented 4 years ago

I recommend using python-twitch client and writing your own script.

I am writting on another language script, but its TOO difficult. I would like to someone fixed this script, because i just dont know python language. I wasted 3 days to fix script and read python forums and manuals, but with no results.

epsilon573 commented 4 years ago

Here : https://github.com/epsilon573/myTwitchBot This doesn't automatically upload to Youtube though.

lxgameshow commented 4 years ago

Here : https://github.com/epsilon573/myTwitchBot This doesn't automatically upload to Youtube though.

Thanks a lot! But i have a problem. Thats says to me (i only set Client Id and Oauth) Upd. Set duration videos in end of file, no results Upd2 - I fixed your bug, still sends me "An Unexpected Match Score!" Can you help me with answer? Where i need to search code to upload videos on Youtube? D:\IDM_DOWNLOADS\myTwitchBot-master>C:\python383\python.exe D:\IDM_DOWNLOADS\myT witchBot-master\main.py An Unexpected Match Score! ...100% Video Downloaded Traceback (most recent call last): File "D:\IDM_DOWNLOADS\myTwitchBot-master\main.py", line 163, in <module> download_clips(data, "--required-video-length--" ) File "D:\IDM_DOWNLOADS\myTwitchBot-master\main.py", line 137, in download_clip s length -= data[clip]["duration"] TypeError: unsupported operand type(s) for -=: 'str' and 'float'

epsilon573 commented 4 years ago

Just search on github, I think you will find plenty.