35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
from django.apps import AppConfig
|
|
from django.http import HttpResponse
|
|
from django.shortcuts import render
|
|
from django.shortcuts import redirect
|
|
import time
|
|
import random
|
|
|
|
def hello(request):
|
|
return HttpResponse('<h1>Hello Simpsons!</h1>')
|
|
|
|
def simpsons(request):
|
|
simpsons_url = "https://www1.kisscartoon.online/episode/the-simpsons-season-";
|
|
number_of_seasons = 35
|
|
seasons_maximum_number = [13,22,24,22,22,25,25,25,25,23,22,21,22,22,22,21,22,22,20,21,23,22,22,22,22,22,22,22,21,23,22,22,22,22,18]
|
|
|
|
#print(simpsons_url)
|
|
|
|
random_seasons = random.randint(1, number_of_seasons)
|
|
print("random seasons: "+ str(random_seasons))
|
|
|
|
#random_seasons-1 because list start at index 0
|
|
print("maximum of episode for this season: "+str(seasons_maximum_number[random_seasons-1]))
|
|
|
|
random_episode = random.randint(1, seasons_maximum_number[random_seasons-1])
|
|
|
|
print("random episode: "+ str(random_episode))
|
|
|
|
|
|
final_url = simpsons_url+str(random_seasons)+ "-episode-"+str(random_episode)#
|
|
print(final_url)
|
|
|
|
# return HttpResponse(str(final_url))
|
|
# time.sleep(10)
|
|
return redirect(str(final_url))
|