Skip to content

Commit

Permalink
init sistemi sadeleştirildi
Browse files Browse the repository at this point in the history
  • Loading branch information
KebabLord committed Jan 30, 2021
1 parent bb15dd9 commit e5980ee
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PyInquirer
questionary
selenium
youtube-dl
bs4
Expand Down
37 changes: 8 additions & 29 deletions turkanime.py
Original file line number Diff line number Diff line change
@@ -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ç",
Expand Down
28 changes: 28 additions & 0 deletions turkanime_api/__init__.py
Original file line number Diff line number Diff line change
@@ -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 """
Expand All @@ -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
)

0 comments on commit e5980ee

Please sign in to comment.