python. Can programming beginners make things randomly? Part 2

No way. This article ends in Part ②. (Lol)

Caution: This post is not a post where you can learn anything. It's just a post where beginners learn programming and write down where they stumbled. .. .. orz

I'm good at python! This guy is worried about something simple. If you have a kind heart, please give me some advice. ..

environment: windows Anaconda3 python3.7.6

What I wanted to complete through this article

Details are described in Part 1 below.

Simply put, download a large number of youtube thumbnails, determine if the thumbnail contains a specific image, and export it to a spreadsheet (Excel). I wanted to do that.

Conclusion: How random it is to complete. .. The actual number of working days is 3 days. In order to write this article, PYTHON was a complete amateur, so I was studying list type, dictionary type, etc. from flow control such as if statements.

Since I work on weekdays, will it take about a month? I was thinking. The overwhelming excellence of the qiita article and the simplicity of PYTHON's grammar helped me. Thank you very much.

What kind of implementation

It's okay to put the code, but since the code isn't pretty as a compliment (or rather dirty), I'll put only the points used for implementation.

YouTube Data API v3 CV2 openpyxl glob It was easy to make using the above four.

The implementation image is (1) Download a large number of thumbnails by date and time sorting using YouTube Data API v3 (2) Cut out the image of a specific card (let's call it A), and use CV2 to determine whether all the images contain A. (3) Export the true judgment result to youtubeURL and the thumbnail image to Excel. Will be.

YouTube Data API v3 First, about YouTube Data API v3. With reference to the following article (or rather, the program is listed), the thumbnail download program has been completed.

The point that took time is that if the article is implemented, it seems that it will sort by date and time and fetch "all videos" in order, but somehow the videos are skipped and acquired. (For example, today's video has 30 videos, so if you want to download 30 thumbnails, 15 videos for today and 15 videos will be skipped 15 videos like past videos. I wonder if it will be transmitted.) The cause has not yet been clarified here. .. .. However, by adding publishedAfter to the search condition, I specified the date and time of the desired video, and it brought me without skipping to some extent. What is it? (Lol)

The code in the article

  videos_response =
    pageToken= next_page_token

After renovation

  videos_response =
    pageToken= next_page_token

There was one more stumbling block. I got caught in API usage restrictions. Should I program it nicely to save money? YouTube Data API v3 is stingy. (Laughs) (There was a description on how to save money in the official reference.) It seems that there is an application to raise the usage limit (it seems that it may be free), but it was difficult to understand and the usage limit will be reset after one day, so I did not apply.

CV2 And then CV2 matchTemplate. This was exactly what I wanted to do. .. (Laughs) In Part 1, I experienced some difficult things such as face recognition technology, but I don't need anything like this.

The following is the reference URL. (Almost all programs are available. Really excellent.) I was very happy when I found this article. I'm not sure because I've just started programming, but how do programmers find the modules they need? I was googled for what I wanted to do, but I want advice from experienced people. .. ..

I had a hard time because I wanted to register the program in cron (scheduling function of linux), so I created it on linux. Build cv2? Couldn't. .. I tried various things as a reference, but the error did not go away. Therefore, I ported the program to windows. Isn't build prone to errors? Since I installed the virtual machine linux used this time with the minimum configuration, I think I will try to install it again in anticipation of various application servers. I wonder if it was built from the beginning? I'm expecting it.

openpyxl and glob

The reference URL is around here: ① Paste a large number of images into Excel. ② Get the file list in the folder with Python ③ How to get only the file name in the folder with python

I think this is pretty general, so I don't really want to write anything about it. (Lol) To put it bluntly, the windows path must overlap with "\", which is just annoying.

Looking back

No, I didn't think it would be so easy. I was prepared for part 10th place. End with ② Death. Next, I want to make an application that can operate the browser.

By the way, youtube is a game called Clash Royale. I was able to snoop on the play of top players with this program. As long as I'm happy. (Lol)


Also, it's fun to make an app and work as expected. I have experienced it for myself. Right now I'm doing DBA with a major SIer, but eventually I'm dreaming that I'd like to do an application development job (with the goal of having fun) as an individual.

Recommended Posts

python. Can programming beginners make things randomly? Part 2
python. Can programming beginners make things randomly? Part ①
I refactored "I tried to make Othello AI when programming beginners studied python"
For new students (Recommended efforts for Python beginners Part 1)
Introduction to Programming (Python) TA Tendency for beginners
How to make Python faster for beginners [numpy]
QGIS + Python Part 2
Let's make an app that can search similar images with Python and Flask Part1
Python programming note
Let's make an app that can search similar images with Python and Flask Part2
QGIS + Python Part 1
Python: Scraping Part 1
Beginners practice Python
Python beginner's note
Python3 Beginning Part 1
Python: Scraping Part 2
Beginners can use Python for web scraping (1) Improved version
Python that I would like to recommend to programming beginners
Building a Python environment for programming beginners (Mac OS)