Skip to content

AndeYashwanth/match-youtube-title-with-view-count

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

clone the repo and run composer install to install googleapi and dotenv(optional).

create a project in google developer console and add youtube data api v3.

You also need to enable OAuth in dev console.

Edit video_id(line 11)(obtained from url of video), api_key(line 12)(obtained from google developer console) and application name(line 15) in main.php.

Download client_secret.json form google developer console and place in same(current) directory.

Open get_auth_code.php file in browser after starting apache2 or xampp.

open the url in new tab and authorise your account to your app.

copy the authorization code from the url to main.php(line 13) and open in browser or run in commandline.

Access token and refresh token along with some metadata like created time and expiry will be stored in accesstoken.json.

views, likes and comments count will be stored in count.json.

If the counts obtained by fetching using yotube data api are different from previously saved count.json then script updates the title.

Run cron job every minute or 30 seconds or how frequently you want depending on your size of audience and quota limit for requests.
crontab -e
add * * * * * /usr/bin/php path/to/main.php at the end of file.

Code obtained from youtube data api v3 docs.

Below video demonstrates working of this script.

https://www.youtube.com/watch?v=ScIe7InaRJI

About

Updates youtube video view count to match the title.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages