Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Added Next And Prev Buttons In Video Player Page #4

Merged
merged 2 commits into from
Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# The command that runs the program. If the interpreter field is set, it will have priority and this run command will do nothing
run = "python3 main.py"

# The primary language of the repl. There can be others, though!
language = "python3"
entrypoint = "main.py"
# A list of globs that specify which files and directories should
# be hidden in the workspace.
hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]

# Specifies which nix channel to use when building the environment.
[nix]
channel = "stable-21_11"

# The command to start the interpreter.
[interpreter]
[interpreter.command]
args = [
"stderred",
"--",
"prybar-python3",
"-q",
"--ps1",
"\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
"-i",
]
env = { LD_LIBRARY_PATH = "$PYTHON_LD_LIBRARY_PATH" }

[env]
VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv"
PATH = "${VIRTUAL_ENV}/bin"
PYTHONPATH = "${VIRTUAL_ENV}/lib/python3.10/site-packages"
REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/"
MPLBACKEND = "TkAgg"
POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry"

# Enable unit tests. This is only supported for a few languages.
[unitTest]
language = "python3"

# Add a debugger!
[debugger]
support = true

# How to start the debugger.
[debugger.interactive]
transport = "localhost:0"
startCommand = ["dap-python", "main.py"]

# How to communicate with the debugger.
[debugger.interactive.integratedAdapter]
dapTcpAddress = "localhost:0"

# How to tell the debugger to start a debugging session.
[debugger.interactive.initializeMessage]
command = "initialize"
type = "request"

[debugger.interactive.initializeMessage.arguments]
adapterID = "debugpy"
clientID = "replit"
clientName = "replit.com"
columnsStartAt1 = true
linesStartAt1 = true
locale = "en-us"
pathFormat = "path"
supportsInvalidatedEvent = true
supportsProgressReporting = true
supportsRunInTerminalRequest = true
supportsVariablePaging = true
supportsVariableType = true

# How to tell the debugger to start the debuggee application.
[debugger.interactive.launchMessage]
command = "attach"
type = "request"

[debugger.interactive.launchMessage.arguments]
logging = {}

# Configures the packager.
[packager]
language = "python3"
ignoredPackages = ["unit_tests"]

[packager.features]
enabledForHosting = false
# Enable searching packages from the sidebar.
packageSearch = true
# Enable guessing what packages are needed from the code.
guessImports = true

# These are the files that need to be preserved when this
# language template is used as the base language template
# for Python repos imported from GitHub
[gitHubImport]
requiredFiles = [".replit", "replit.nix", ".config", "venv"]

[languages]

[languages.python3]
pattern = "**/*.py"

[languages.python3.languageServer]
start = "pylsp"
7 changes: 0 additions & 7 deletions Dockerfile

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
2 changes: 1 addition & 1 deletion index.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from wsgi import app
from run.wsgi import app
132 changes: 132 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
from programs.html_gen import animeRecHtml, episodeHtml, get_eps_html, get_recent_html, get_search_html, get_selector_btns, get_genre_html, get_trending_html, slider_gen
from flask import Flask, render_template, request, redirect
from programs.anilist import Anilist
from programs.others import get_atitle, get_other_title, get_studios, get_t_from_u
from programs.gogo import GoGoApi
GOGO = GoGoApi()
app = Flask(__name__)


@app.route('/')
def hello_world():
html = render_template('home.html')
div1 = get_trending_html()
div2 = get_recent_html(GOGO.home())
sliders, slider = slider_gen()

html = html.replace(
'MOST_POPULAR',
div1
).replace(
'RECENT_RELEASE',
div2
).replace(
'SLIDERS',
sliders
)
return html


@app.route('/embed')
def get_embed():
url = request.args.get('url')
if url and '.m3u8' not in url:
return redirect(url)

if '.m3u8' in url or '.mp4' in url or '.mkv' in url:
file = url
else:
file = request.args.get('file')
sub = request.args.get('sub')
title = request.args.get('title')
if sub != None:
track = """tracks: [{
"kind": "captions",
file: "sopu",
label: 'English',
"default": true
}],""".replace('sopu', sub)
else:
track = ''

return render_template('vid.html', m3u8=file, title=title).replace('TRACKS', track)


@app.route('/episode/<anime>/<episode>')
def get_episode(anime, episode):
anime = get_t_from_u(anime)
search = GOGO.search(anime, True)

total_eps = GoGoApi().get_episodes(search[0])

eps = GOGO.get_links(search[0], episode)
btn_html = get_selector_btns(f"/episode/{anime}/", int(episode), int(total_eps))
ep_html, iframe = episodeHtml(eps, f'{anime} - Episode {episode}')

temp = render_template(
'episode.html',
title=f'{anime} - Episode {episode}',
heading=anime,
iframe=iframe
)

return temp.replace('PROSLO', btn_html).replace('SERVER', ep_html)


@app.route('/anime/<anime>')
def get_anime(anime):
if '.' in anime:
anime = anime.split('.')[0].replace('-', ' ')
data = Anilist.anime(get_t_from_u(anime))

title = get_atitle(data.get('title'))
synopsis = data.get('description')
names = get_other_title(data.get('title'))
studios = get_studios(data.get('studios'))
episodes = str(data.get('totalEpisodes'))
genres = get_genre_html(data.get('genres'))
displayAnime = animeRecHtml(data.get('recommendations'))
ep_html = get_eps_html(anime, title)

html = render_template('anime.html',
img=data.get('image'),
title=title,
DUB=data.get('type'),
SEASON=data.get('season'),
other=names,
studios=studios,
episodes=episodes,
year=data.get('releaseDate'),
ATYPE=data.get('type'),
status=data.get('status'),
animeURL=f'/anime/{anime}',
WATCHNOW=f'/episode/{anime}/1',
aid=anime
)

html = html.replace('GENEROS', genres)
html = html.replace('EPISOS', ep_html)
html = html.replace('DISPLAY_ANIME', displayAnime)
html = html.replace('SYNOP', synopsis)
return html


@app.route('/search', methods=['GET'])
def search_anime():
anime = request.args.get('query')

html = render_template('search.html',
aid=anime.replace('+', ' '))

data = Anilist.search(anime)
display = get_search_html(data)

html = html.replace(
'SEARCHED',
display
)
return html


if __name__ == '__main__':
app.run('0.0.0.0')
30 changes: 11 additions & 19 deletions programs/html_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,49 +125,41 @@ def get_recent_html(data):
return html


def get_selector_btns(anime, current, episodes: list):
ids = []
for i in episodes:
ids.append(i['id'])

li = ids

if len(li) < 2:
def get_selector_btns(url, current, episodes: list):
if episodes < 2:
return '', 0

index = li.index(current)
selector = ''
a = int(len(li)-1)

if int(index) == 0:
if current == 1:
x = """<a class="btns" href="usrl"><button
class="sbtn inline-flex text-white bg-indigo-500 border-0 py-2 px-6 focus:outline-none hover:bg-indigo-600 rounded text-lg ">Episode NEXT<i style="margin-left:10px; margin-right: auto;" class="fa fa-arrow-circle-right"></i></button></a>"""

selector += x.replace('usrl', anime +
episodes[1]['id']).replace('NEXT', str(episodes[1]['number']))
selector += x.replace('usrl', url +
str(current+1)).replace('NEXT', str(current+1))

elif int(index) == a:
elif current == episodes:
x = """<a class="btns" href="usrl"><button
class="sbtn inline-flex text-white bg-indigo-500 border-0 py-2 px-6 focus:outline-none hover:bg-indigo-600 rounded text-lg "><i
class="fa fa-arrow-circle-left"></i>Episode PREV</button></a>"""

selector += x.replace('usrl', anime + episodes[index-1]['id']).replace(
'PREV', str(episodes[index-1]['number']))
selector += x.replace('usrl', url + str(current-1)).replace(
'PREV', str(current-1))

else:
x = """<a class="btns" href="usrl"><button
class="sbtn inline-flex text-white bg-indigo-500 border-0 py-2 px-6 focus:outline-none hover:bg-indigo-600 rounded text-lg "><i
class="fa fa-arrow-circle-left"></i>Episode PREV</button></a>"""

selector += x.replace('usrl',
anime + episodes[index-1]['id']).replace('PREV', str(episodes[index-1]['number']))
url + str(current-1)).replace('PREV', str(current-1))

x = """<a class="btns" href="usrl"><button
class="sbtn inline-flex text-white bg-indigo-500 border-0 py-2 px-6 focus:outline-none hover:bg-indigo-600 rounded text-lg ">Episode NEXT<i style="margin-left:10px; margin-right: auto;" class="fa fa-arrow-circle-right"></i></button></a>"""

selector += x.replace('usrl',
anime + episodes[index+1]['id']).replace('NEXT', str(episodes[index+1]['number']))
return selector, index
url + str(current+1)).replace('NEXT', str(current+1))
return selector


SLIDER_HTML = """<div class="mySlides fade">
Expand Down
2 changes: 1 addition & 1 deletion programs/vidstream.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_crypto(url):
function to get crypto data
'''
r = requests.get(url)
soup = bs(r.content, 'lxml')
soup = bs(r.content, 'html.parser')
for item in soup.find_all('script', attrs={'data-name': 'episode', 'data-value': True}):
crypto = str(item['data-value'])
return crypto
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ gunicorn
requests
bs4
flask
lxml
cssselect
regex
yarl
Expand Down
Loading