Skip to content

Instantly share code, notes, and snippets.

@abeeku
Created October 15, 2017 06:31
Show Gist options
  • Save abeeku/0ad84c00f37f4afca9d7616f1cbd80cf to your computer and use it in GitHub Desktop.
Save abeeku/0ad84c00f37f4afca9d7616f1cbd80cf to your computer and use it in GitHub Desktop.
Spongebob Squarepants
#!/usr/bin/python2
from selenium import webdriver
import time
firefoxProfile = webdriver.FirefoxProfile()
from bs4 import BeautifulSoup
import subprocess
import random
import requests
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
firefoxProfile.set_preference('permissions.default.stylesheet', 2)
## Disable images
firefoxProfile.set_preference('permissions.default.image', 2)
## Disable JavaScript
firefoxProfile.set_preference('javascript.enabled', False)
## Disable Flash
firefoxProfile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so','false')
## Use the driver
browser = webdriver.Firefox(firefoxProfile)
def watch(url, seas):
browser.get(url)
browser.set_window_size(0, 0)
#time.sleep(10)
try:
wait = browser.WebDriverWait(browser,10).until(EC.presence_of_element_located(By.NAME,'video'))
finally:
pass
#if seas == 2:
# time.sleep(6)
soup = BeautifulSoup(browser.page_source, "lxml")
browser.close()
vid = soup.find("video").get("src")
subprocess.call(["mpv", vid])
seas = random.randint(1,9)
if seas == 1:
seasonUrl = "https://kisscartoon.cc/3028-2/"
elif seas == 2:
seasonUrl = "https://kisscartoon.cc/__trashed/"
else:
seasonUrl = "https://kisscartoon.cc/spongebob-squarepants-season-%s/" % seas
print(seasonUrl)
req = requests.get(seasonUrl)
sesoup = BeautifulSoup(req.text, "lxml")
watch(random.choice(sesoup.find("table").find_all("a")).get("href"), seas)
#print ep
#watch(ep.get("href"))
#side = random.choice(['A','B'])
#url = "https://kisscartoon.cc/spongebob-squarepants-season-%s/season/1/episode/%s%s/"% (seas, epnun, side)
#url = raw_input("Enter url: ")
#watch(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment