Skip to content

Commit

Permalink
Added OTP Login.
Browse files Browse the repository at this point in the history
  • Loading branch information
henry-richard7 committed May 31, 2024
1 parent 2b9ff2b commit 158bfc2
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Modules/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def get_channels(self):
with open(r"data\channels.json", "w") as f:
json.dump(response, f, ensure_ascii=False, indent=4)

def sendOTP(mobile):
def sendOTP(self, mobile):
body = {
"identifier": mobile,
"otpIdentifier": mobile,
Expand Down Expand Up @@ -127,7 +127,7 @@ def login(self, email, password, mode="unpw"):
"""
body = {
"identifier": email,
"password": password,
"password" if mode == "unpw" else "otp": password,
"rememberUser": "T",
"upgradeAuth": "Y",
"returnSessionDetails": "T",
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ JioTV proxy developed using Python and FastAPI framework.

- For Sony Liv channels I have added direct stream links instead of JIO-TV stream. [Found It From Here.](https://github.com/dhruv-2015/JIOTVServer/blob/main/utils/genPlaylist.mjs)

- (2024-05-31) Added OTP login.

# How to use (From Binary)

- Download the latest for your platform from [Releases](https://github.com/henry-richard7/JioTV-Proxy/releases)
- Run JioTV file.
- Login to your Jio Account at http://localhost:8000/login.
- Login to your Jio Account using Email at http://localhost:8000/?mode=unpw.
- Login to your Jio Account using OTP at http://localhost:8000/?mode=otp.
- To play live channels on web http://localhost:8000.
- To play live channels in media player such as vlc http://localhost:8000/playlist.m3u
- To play live channels on your local network http://<your_local_ip>:8000/playlist.m3u (You can get this from console when running the app.)
Expand All @@ -23,6 +26,7 @@ JioTV proxy developed using Python and FastAPI framework.
- Follow the above steps.

# Known Issues

- CN HD+ Tamil: It is noted that Cartoon Network HD+ Tamil channel does not work under API v2.0 but working in v2.1. Using v2.1 breaks other channels. Need to find a way to use v2.1 endpoint if currently playing channel is CN HD+ Tamil.
- Sony channels are not playing in Web Browser. This is due to **CORS**. To workaround Need to install [Cors Bypass Extension](https://chromewebstore.google.com/detail/cors-unblock/lfhmikememgdcahcdlaciloancbhjino?pli=1)

Expand Down
21 changes: 16 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ def welcome_msg():
print("===================================================")
print("Welcome to JioTV-Proxy")
print(f"Web Player: http://{localip}:8000/")
print(f"Please Login at http://{localip}:8000/login")
print(
f"Please Login Using Email and Password at http://{localip}:8000/login?mode=unpw"
)
print(f"Please Login Using OTP at http://{localip}:8000/login?mode=otp")
print(f"Playlist m3u: http://{localip}:8000/playlist.m3u")
print("===================================================")
print()
Expand Down Expand Up @@ -193,7 +196,7 @@ async def middleware(request: Request, call_next):
Returns:
- Response: The HTTP response object to be sent back to the client.
"""
if request.url.path in ["/login", "/playlist.m3u", "/createToken"]:
if request.url.path in ["/login", "/playlist.m3u", "/createToken", "/get_otp"]:
response = await call_next(request)
return response

Expand All @@ -213,7 +216,7 @@ async def middleware(request: Request, call_next):
elif token_check == "Expired":
email, password, login_mode = get_creds()

if login_mode == "":
if login_mode == "unpw":
jiotv_obj.login(email, password)
update_expire_time(email=email, password=password)
jiotv_obj.update_headers()
Expand All @@ -236,6 +239,11 @@ async def middleware(request: Request, call_next):
return response


@app.get("/get_otp")
def get_otp(phone_no):
return jiotv_obj.sendOTP(phone_no)


@app.get("/createToken")
def createToken(email, password, mode):
"""
Expand Down Expand Up @@ -266,7 +274,7 @@ def createToken(email, password, mode):


@app.get("/login")
async def loginJio(request: Request):
async def loginJio(request: Request, mode: str):
"""
Get the login page.
Expand All @@ -276,7 +284,10 @@ async def loginJio(request: Request):
Returns:
TemplateResponse: The response containing the login page HTML template.
"""
return templates.TemplateResponse("login.html", {"request": request})
if mode == "unpw":
return templates.TemplateResponse("login.html", {"request": request})
elif mode == "otp":
return templates.TemplateResponse("otp_login.html", {"request": request})


@app.get("/playlist.m3u")
Expand Down
5 changes: 4 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
>
</li>
<li class="nav-item">
<a class="nav-link" href="/login">Login</a>
<a class="nav-link" href="/login?mode=unpw">Login With Email</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/login?mode=otp">Login With OTP</a>
</li>
</ul>
</div>
Expand Down
187 changes: 187 additions & 0 deletions templates/otp_login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
<html>

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>JIO TV Login</title>
<style>
body {
font-family: "Lato", sans-serif;
}


.main-head {
height: 150px;
background: #FFF;

}

.sidenav {
height: 100%;
background-color: rgb(167, 29, 29);
overflow-x: hidden;
padding-top: 20px;
}


.main {
padding: 0px 10px;
}

@media screen and (max-height: 450px) {
.sidenav {
padding-top: 15px;
}
}

@media screen and (max-width: 450px) {
.login-form {
margin-top: 10%;
}

.register-form {
margin-top: 10%;
}
}

@media screen and (min-width: 768px) {
.main {
margin-left: 40%;
}

.sidenav {
width: 40%;
position: fixed;
z-index: 1;
top: 0;
left: 0;
}

.login-form {
margin-top: 80%;
}

.register-form {
margin-top: 20%;
}
}


.login-main-text {
margin-top: 20%;
padding: 60px;
color: #fff;
}

.login-main-text h2 {
font-weight: 300;
}

.btn-black {
background-color: #000 !important;
color: #fff;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>

<body>

<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

<!------ Include the above in your HEAD tag ---------->

<div class="sidenav">
<div class="login-main-text">
<h2>JIO TV<br> Login Page</h2>
<p>Login To JIO TV to start watching Live TV.</p>
</div>
</div>


<div class="main">
<div class="col-md-6 col-sm-12">
<div class="login-form">

<div class="form-group"></div>
<label>Mobile Number</label>
<!--<input type="text" class="form-control" placeholder="Email" id="email">-->
<div class="input-group mb-3">
<span class="input-group-text" id="basic-addon1">+91</span>
<input type="number" class="form-control" placeholder="Mobile Number" aria-label="Mobile Number" aria-describedby="basic-addon1" id="email">
</div>
</div>
<div class="form-group">
<label>OTP</label>
<input type="number" class="form-control" placeholder="OTP" id="password">
</div>

<button onclick="process_otp()" class="btn btn-black">Get OTP</button>
<button onclick="enviar()" class="btn btn-black" id="login-btn" disabled>Login</button>

</div>
</div>
</div>

<script>
function enviar() {

var email = "%2B91"+$("#email").val();
var passsword = $("#password").val();

console.log();
setTimeout(
function () {
$.ajax({
url: '/createToken?email=' + email + '&password=' + passsword+ '&mode=otp',
type: 'GET',
async: true,
success: function (result) {
if (result === "[SUCCESS]") {
console.log(result)
alert("Successfully Logged In")
} else if (result === "[FAILED]") {
alert("Failed To Login check Email & Password!")

}

}
});
}, 500);

}
function process_otp(){
var email = "%2B91"+$("#email").val();

console.log(email);

//$("#login-btn").prop("disabled",false)
setTimeout(
function () {
$.ajax({
url: '/get_otp?phone_no=' + email,
type: 'GET',
async: true,
success: function (result) {
if (result === "[SUCCESS]") {
alert("OTP Sent Successfully.")
$("#login-btn").prop("disabled",false)
} else if (result === "[FAILED]") {
alert("Unable to send OTP!.")

}

}
});
}, 500);

}
</script>


</body>

</html>

0 comments on commit 158bfc2

Please sign in to comment.