Downloading Anime Series Automatically (using pyautogui)

 


In this article, we will learn how to use pyautogui and download a whole anime series using pyautogui in python.

First of all, we have to install pyautogui on our computer and for that, we will use pip(preferred package installer) so use the following line on your PC terminal

>>> pip install pyautogui


Next, we will install selenium on our PC 
We will use selenium for open chrome browser. To install selenium write the following line your terminal

>>> pip install selenium

   

Now we will check the version of chrome on your our computer for that go to chrome://settings/help


After knowing your chrome version go to https://chromedriver.chromium.org/downloads and download the chrome driver of your chrome version.

After installing make a new folder on your PC and make .py file in that folder. and move the downloaded chromedriver.exe file to that folder.
Now your folder structure will look like this:


Now let's start the actual coding, in your .py file we will import webdriver from selenium and pyautogui as pg and sleep from the time module

from selenium import webdriver
import pyautogui as pg
from time import sleep

Here the resolution of your screen matters, Mine is 1366x786
write the following code in your file
here driver path will the full path of your chromedriver.exe file

DRIVER_PATH = 'E:\Collage Work\Programming\Python\chromedriver.exe'
driver = webdriver.Chrome(executable_path=DRIVER_PATH)

now we will create a for loop for download multiple episodes 
for i in range(0, 13):
    url = ('https://www.wcostream.com/high-school-dxd-hero-episode-'+str(i)+'-english-
    dubbed')
    driver.get(url)  # Now the target url is opened in new tab
    pg.scroll(-1100)
    pg.click(x=500, y=500)
    sleep(3)
    pg.rightClick(x=500, y=500)
    sleep(3)
    pg.click(x=600, y=600)
    sleep(4)
    pg.write('High School DxD S4'+'E1'+str(i))
    pg.press('Enter')
    sleep(10) 

in this we have some pyautogui function like scroll and click

I am using wcostream for downloading anime episodes,
first, the program will open the chrome browser and then open the following URL given by the for loop, and then the pgautogui will do its work like scroll to the video and start. After starting the video it will right-click on it and click the save video option. After clicking on the save video type the anime name and the episode number dynamically. After all this, it will press enter and wait for 10 seconds. After completing the first loop the whole process will be repeated but every time the new link will open to download a new episode.

Thanks for reading the article, comment to suggest any improvement in my articles because I am still learning.

Post a Comment

Previous Post Next Post