Upload Video Youtube From Command Line Python

Youtube menyediakan api untuk kita bisa manajemen video yang ada dalam chanel kita. Dengan Api ini memungkinkan untuk kita untuk terus bisa upload data video misalnya dengan menggunakan bahasa pemrograman apapun, salah satunya python.

Sebagai youtuber / publisher ads pemula, salah satu trik yang sering dipakai adalah dengan menembakkan video dari lokal dengan menggunakan perintah sesuai dengan video yang diupload. Ini akan menjadi automatik jika video yang kita upload merupakan hasil dari video yang kita download dengan menggabungkan beberapa video yang lain dan menguploadnya kembali sebagai video unik baru sebagai video monetize. Dan asyiknya itu kalo dah jalan kita tinggal pasang saja satu server, buat timer/schedule untuk stay up to date chanel kita. Ini akan menjadi bagus ketika model scrapping ini kita bisa terapkan dan tanpa kena suspend dari google.


Pastikan sudah terinstall git bash dan python versi 3, tutorial ada di grup https://www.facebook.com/groups/1631160323785934
  1. Download scriptnya di https://github.com/tokland/youtube-upload
  2. Unzip
  3. Buka git bash, lalu masukkan command : 

$pip install --upgrade google-api-python-client progressbar2
$python setup.py install 



untuk yang linux tinggal eksekusi saja di terminal

4. Jika sudah terinstall, coba dulu scriptnya work apa nggak, masukkan command : youtube-upload -h

5. Selanjutnya, buat oauth 2.0 file :
- masuk ke https://console.developers.google.com/
- buat project baru
- aktifkan API
- buat OAuth consent screen
- buat credentials, OAuth client id type other
- edit client_secrets.json  atau gunakan json hasil download letakkan dibagian /usr/local/share/youtube_upload/client_secrets.json atau posisi dimana letak client_secrets.json saat proses instalasi youtube_upload

6. Kita coba upload, buka git bash di folder tempat video berada, kemudian masukkan command sesuai keinginan, misal

Verifikasi dulu channel yg akan diupload videonya

TUNGGU PROSESNYA , hehe kadang kadang error juga

Jika sudah berhasil, akan ada pemberitahuan

Playlist akan otomatis jika sebelumnya belum pernah membuat di channel, coba kita cek


7. Kategori :
Film & Animation
Autos & Vehicles
Music
Pets & Animals
Sports
Short Movies
Travel & Events
Gaming
Videoblogging
People & Blogs
Comedy
Entertainment
News & Politics
Howto & Style
Education
Science & Technology
Movies
Anime/Animation
Action/Adventure
Classics
Documentary
Drama
Family
Foreign
Horror
Sci-Fi/Fantasy
Thriller
Shorts
Shows
Trailers

8. File credential biasanya ada di folder C:\Users\name\.youtube-upload-credentials.json  untuk yang linux bisa dilihat /home/user/.youtube-upload-credentials.json

Kalau mau upload di chanel lain, hapus file credential itu, atau buat baru, misal

youtube-upload --title="Virtual memori komputer" --description="komputer dengan virtual meory" --category="Science & Technology" --tags="Virtual Memory" --thumbnail "Screenshot_229.png" --privacy "Public" outputvideo_vIRTUALmEMORY.mp4


note : file .youtube-upload-credentials.json akan dibuatkan otomatis dari aktivitas upload yang kita lakukan, json yang perlu kita siapkan adalah client_secrets.json

How To Configure MySQL Allow Remote Access Connection

Hot To Configure MySQL Allow Remote Access Connection

1. You must create 
    set bind-address : /etc/my.cnf
    bind-address 0.0.0.0

    It will be set Database can allow from any network on IP4

2. Create user mysql for allowing that user can access remotely

    GRANT ALL PRIVILEGES ON *.* TO db_user @'10.10.151.30' IDENTIFIED BY 'db_passwd';
    [-] GRANT ALL PRIVILAGES : to manage privilage for db_user
    [-] *.*  : to allow db_user access any database and table can. It will be *.* --> [database].[spesific table]
    [-] db_user : user that will be create to have that privilage
    [-] @'10.10.151.30' : Source of Ip address user database. That's mean allowing connection from 10.10.151.30
    [-] IDENTIFIED BY 'db_passwd' : Create Password for db_user

3.  If you want to access from localhost too, it must create user from locahost access also
    ex :
        - GRANT ALL PRIVILEGES ON *.* TO db_user @'127.0.0.1' IDENTIFIED BY 'db_passwd';
        OR
        - GRANT ALL PRIVILEGES ON *.* TO db_user @'localhost' IDENTIFIED BY 'db_passwd';

4. To close the vulnerability, cause this will be allow connection from any host. Create Firewall for Drop anythings come to port Mysql(3306) and than allow specified IP Address to access from remote.
    ex :
               
        - DROP ALL Connection to port 3307 (this case database working with port 3307)
            $sudo /sbin/iptables -A INPUT -p tcp --dport 3307 -j DROP

        - ACCEPT Specified address to acces port 3307 from network
           
            $sudo /sbin/iptables -A INPUT -p tcp -d 10.10.70.3 --dport 3307 -j ACCEPT
            $sudo /sbin/iptables -A INPUT -p tcp -s 10.10.70.3 --dport 3307 -j ACCEPT
            $sudo /sbin/iptables -A INPUT -p tcp -d 10.10.151.30 --dport 3307 -j ACCEPT
            $sudo /sbin/iptables -A INPUT -p tcp -s 10.10.151.30 --dport 3307 -j ACCEPT

    if you not familiar with iptables you can used

    *) another complate set iptables;
        Even you can allow outgoing MySql client request (made via mysql command line client or perl/php script), from firewall host 202.54.1.20 as follows:           
            $iptables -A OUTPUT -p tcp -s 202.54.1.20 --sport 1024:65535 -d 0/0 --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT
            $iptables -A INPUT -p tcp -s 0/0 --sport 3306 -d 202.54.1.20 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT

           
    *) another way to use ufw (Uncomplicated Firewall) command :
            $sudo ufw allow 3306
            ## only allow subnet 192.168.1.0/24 to connect to our mysql server ##
            $sudo ufw allow from 192.168.1.0/24 to any port 3306

       
5. Enjoyed! Just like that


F.A.Q :

How Do I Grant Access To An Existing Database?

Let us assume that you are always making connection from remote IP called 202.54.10.20 for database called webdb for user webadmin, To grant access to this IP address type the following command At mysql> prompt for existing database, enter:
mysql> update db set Host='202.54.10.20' where Db='webdb';
mysql> update user set Host='202.54.10.20' where user='webadmin';


Some Referece :
- https://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
- https://www.cyberciti.biz/tips/linux-iptables-18-allow-mysql-server-incoming-request.html
- https://www.percona.com/doc/percona-xtrabackup/2.3/howtos/enabling_tcp.html