diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b7cee4c..10c7371 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: with: args: | pip install --upgrade pyOpenSSL; - pip install selenium bs4 PyInquirer easygui; + pip install -r requirements.txt; pylint -E **/*.py && pylint turkanime_api/ --fail-under 8.2 && pylint turkanime.py --fail-under 9.2 diff --git a/requirements.txt b/requirements.txt index 8e385ab..2a9875a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -PyInquirer +questionary selenium youtube-dl bs4 diff --git a/turkanime.py b/turkanime.py index 119507a..b8a6237 100755 --- a/turkanime.py +++ b/turkanime.py @@ -1,40 +1,19 @@ -from os import name,path,mkdir +""" TürkAnimu Downloader v5.2 """ +from os import path,mkdir from atexit import register from configparser import ConfigParser -from time import sleep import questionary -from selenium import webdriver -from selenium.webdriver.firefox.options import Options -from turkanime_api import AnimeSorgula,Anime,gereksinim_kontrol + +from turkanime_api import AnimeSorgula,Anime,gereksinim_kontrol,elementi_bekle,webdriver_hazirla print('TürkAnimu İndirici - github/Kebablord') gereksinim_kontrol() - -def at_exit(): # Program kapatıldığında - print(" "*50+"\rProgram kapatılıyor..",end="\r") - driver.quit() -register(at_exit) - -print(" "*50+"\rSürücü başlatılıyor...",end="\r") - -options = Options() -options.add_argument('--headless') -profile = webdriver.FirefoxProfile() -profile.set_preference("dom.webdriver.enabled", False) -profile.set_preference('useAutomationExtension', False) -profile.set_preference('permissions.default.image', 2) -profile.set_preference("network.proxy.type", 0) -profile.update_preferences() -desired = webdriver.DesiredCapabilities.FIREFOX -if name == 'nt': - driver = webdriver.Firefox(profile, options=options,service_log_path='NUL', executable_path=r'geckodriver.exe', desired_capabilities=desired) -else: - driver = webdriver.Firefox(profile, options=options, service_log_path='/dev/null',desired_capabilities=desired) - +driver = webdriver_hazirla() +register(lambda: (print("Program kapatılıyor..",end="\r") or driver.quit())) driver.get("https://turkanime.net/kullanici/anonim") -sleep(7) - +elementi_bekle(".navbar-nav",driver) sorgu = AnimeSorgula(driver) + while True: islem = questionary.select( "İşlemi seç", diff --git a/turkanime_api/__init__.py b/turkanime_api/__init__.py index 0759a5a..49eeb05 100644 --- a/turkanime_api/__init__.py +++ b/turkanime_api/__init__.py @@ -1,6 +1,10 @@ from sys import exit as kapat import subprocess as sp +from os import name +from selenium import webdriver +from selenium.webdriver.firefox.options import Options from .anime import AnimeSorgula,Anime +from .players import elementi_bekle def gereksinim_kontrol(): """ Gereksinimlerin erişilebilir olup olmadığını kontrol eder """ @@ -16,3 +20,27 @@ def gereksinim_kontrol(): if eksik: print(stdout+"\nBelirtilen program yada programlar, program dizininde yada sistem PATH'ında bulunamadı. Lütfen klavuzdaki kurulum talimatlarını uygulayın.") kapat(1) + +def webdriver_hazirla(): + """ Selenium webdriver'ı hazırla """ + print(" "*50+"\rSürücü başlatılıyor...",end="\r") + + options = Options() + options.add_argument('--headless') + profile = webdriver.FirefoxProfile() + profile.set_preference("dom.webdriver.enabled", False) + profile.set_preference('useAutomationExtension', False) + profile.set_preference('permissions.default.image', 2) + profile.set_preference("network.proxy.type", 0) + profile.update_preferences() + desired = webdriver.DesiredCapabilities.FIREFOX + if name == 'nt': + return webdriver.Firefox( + profile, options=options,service_log_path='NUL', + executable_path=r'geckodriver.exe', desired_capabilities=desired + ) + + return webdriver.Firefox( + profile, options=options, + service_log_path='/dev/null',desired_capabilities=desired + )