From b40c1b3584eaead90184baaeb0849363aa14575f Mon Sep 17 00:00:00 2001 From: datta07 Date: Tue, 21 Feb 2023 00:47:38 +0530 Subject: [PATCH] adding updated sorce apis --- Procfile | 1 + README.md | 27 ++++++ app.json | 13 +++ app.py | 58 ++++++++++++ requirements.txt | 4 + sch/Details.txt | 33 +++++++ sch/__init__.py | 0 sch/__pycache__/__init__.cpython-310.pyc | Bin 0 -> 199 bytes sch/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 157 bytes sch/__pycache__/main_fun.cpython-310.pyc | Bin 0 -> 4429 bytes sch/__pycache__/main_fun.cpython-37.pyc | Bin 0 -> 1852 bytes sch/categories.json | 1 + sch/channel.json | 1 + sch/main_fun.py | 116 +++++++++++++++++++++++ sch/updater.py | 33 +++++++ 15 files changed, 287 insertions(+) create mode 100644 Procfile create mode 100644 README.md create mode 100644 app.json create mode 100644 app.py create mode 100644 requirements.txt create mode 100644 sch/Details.txt create mode 100644 sch/__init__.py create mode 100644 sch/__pycache__/__init__.cpython-310.pyc create mode 100644 sch/__pycache__/__init__.cpython-37.pyc create mode 100644 sch/__pycache__/main_fun.cpython-310.pyc create mode 100644 sch/__pycache__/main_fun.cpython-37.pyc create mode 100644 sch/categories.json create mode 100644 sch/channel.json create mode 100644 sch/main_fun.py create mode 100644 sch/updater.py diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..dc46f1b --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn main:app \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..8fece45 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Tv Channel Schedule Api + API for Indian Tv channel schedule. + +## List of api services:- + /getCategories:- + Json response of languages list and channel categories list. + /searchChannel:- + args:- lang(optional),cate(optional) + Json response of sorted Channels on bases of language and categories. + /TodaySchedule:- + args:- channel + Json response for todays schedule of respective Channel. + /Schedule:- + args:- channel,offset(optional) + offset values as -1 for yesterday,0 for today,1 for tomorrow + Json response for channel schedule on offset day + /GetTodaysMovies:- + args- lang,offset(optional) + offset values as -1 for yesterday,0 for today,1 for tomorrow + Text for particular day movies in a language + +## List of Test urls:- +Click here :- https://rapidapi.com/Garuda07/api/indian-tv-schedule + + +## You can fork the repo and deploy on VPS or deploy it on Heroku :) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/datta07/tv-channel-schedule-api/tree/master) diff --git a/app.json b/app.json new file mode 100644 index 0000000..0ba28d0 --- /dev/null +++ b/app.json @@ -0,0 +1,13 @@ +{ + "name": "Channel-Schedule-Api", + "description": "Api for getting indian Channels dialy schedule", + "keywords": [ + "flask", + "python", + "Channels", + "schedule", + "Channel-Schedule" + ], + "success_url": "https://github.com/datta07/tv-channel-schedule-api", + "repository": "https://github.com/datta07/tv-channel-schedule-api" +} \ No newline at end of file diff --git a/app.py b/app.py new file mode 100644 index 0000000..e38fa76 --- /dev/null +++ b/app.py @@ -0,0 +1,58 @@ +from sch import main_fun +from flask import Flask,send_file,current_app,request,jsonify +from flask_cors import CORS + +app = Flask(__name__) +CORS(app) + + +@app.route('/') +def home(): + return "generic api services @garudadev.com" + +@app.route('/getCategories') +def getCategories(): + return jsonify(main_fun.getCategories()) + +@app.route('/searchChannel') +def searchChannel(): + lang,cate=False,False + if ("lang" in request.args): + lang=request.args["lang"] + if ("cate" in request.args): + cate=request.args["cate"] + try: + return jsonify(main_fun.searchChannel(lang,cate)) + except Exception as e: + print(str(e)) + return "failed:invalid parameters or no parameters,
search /getCategories" + +@app.route('/TodaySchedule') +def TodaySchedule(): + channel=False + offset=0 + if ("channel" in request.args): + channel=request.args["channel"] + return jsonify(main_fun.TodaySchedule(channel,offset)) + +@app.route('/Schedule') +def Schedule(): + channel=False + offset=0 + if ("channel" in request.args): + channel=request.args["channel"] + if ("offset" in request.args): + offset=request.args["offset"] + return jsonify(main_fun.TodaySchedule(channel,offset)) + +@app.route('/GetTodaysMovies') +def GetTodaysMovies(): + lang=False + offset=0 + if ("lang" in request.args): + lang=request.args["lang"] + if ("offset" in request.args): + offset=request.args["offset"] + return main_fun.GetTodaysMovies(lang,offset) + +#app.run() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..dd966d6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +Flask +gunicorn +requests +flask-cors \ No newline at end of file diff --git a/sch/Details.txt b/sch/Details.txt new file mode 100644 index 0000000..53e2e24 --- /dev/null +++ b/sch/Details.txt @@ -0,0 +1,33 @@ +- Heroku App for All Channel Schedule:- + (Integrate with github) + - Create a Github public repo on name "all tv channel schedule" + - Create a Heroku app for its deployment "Garudadev + + +- python file deals with routing (main.py) + - /TodaySchedule?chnl=maatv + - /getCategories + - /searchChannel?lang=Telugu&cate=Movies + +- json file for categories (sch/categories.json) + +- json file for All Channel list (sch/channel.json) + +- python file to update the other json files (sch/update.py) + +- python file for all routing functions (sch/main_fun.py) + +Folder Structure:- + - Garudadev + -sch + -categories.json + -channel.json + -Details.txt + -updater.py + -main.py +e +"previous schedules will be soon" + + + + diff --git a/sch/__init__.py b/sch/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sch/__pycache__/__init__.cpython-310.pyc b/sch/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c0ffaaa01cf1f58e08e7c90a129e6c31b818b063 GIT binary patch literal 199 zcmd1j<>g`k0-e2|lR@-j5P=LBfgA@QE@lA|DGb33nv8xc8Hzx{2;x_kvsFxJacWU< zOk#FvPGXFIUaCt`W?5>COKNd;Nq#|0dSX#&N}_R0UTV2+NtteOaz<)OX-=wcVnJq1 zNSUs4Mq*xGYL0F&Ox!WRQ#UuUxFoeG2Bg`k0*A(ZaUl9Jh=2h`Aj1KOi&=m~3PUi1CZpdI zlbBtalNjTYTAW>yUl5a?SX7#lXdL5Mkm-_Ikdt4To0?Y=;|>;0NiB;hPR@vlkI&4@ aEQycTE2zB1VUwGmQks)$2Qt4Hh#3IyqbK(O literal 0 HcmV?d00001 diff --git a/sch/__pycache__/main_fun.cpython-310.pyc b/sch/__pycache__/main_fun.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f51303fc0ed590421b072b25e847ca9567df1713 GIT binary patch literal 4429 zcmb7H&2JmW6`z@1E|(N3DUK6aNt&=u;+knhS+-+K{z&Y|aS*^!3Oi1ag$iQD8A&UV zOKNs0Tf`Cw;2e5Mg7#1#Kn_&V0yWS}&+Vx||B1c!lyfhIP}KdsS&{m%Q=laF?VH&* zGjHGfy^n2|%SDFY-M{~{F+a}OKWK3HXJc>!SM(4>GRd3F%kJFc7>lN8S)RqSIpK*9 znY5(+6_d8I9$B6(b6!q5GA~_O_}=myS(Ia6F)uG)kYzdk757~EqMVSE;0kg|J||Cr zD`M_>c@o^1#I{Btn4fh)QKq8RDs3CYc01kiicF?w;& zlF$bl*rXHgIa!cJ+#Pe$So%VC!skJ}epkg^9e(CFyK3n%Yvi%@@JGChYY|s;79?f^ zp0I=`BC!%X$?ZC1lZ4epYz^#P;&PJRV~_b#)zJbgQny|Y!XU2K(|lcg`4z|_uEfsCzkmWUBccp(}IaCj3;_aEJv94sd zsb>66u>9%v%;LHqhN?MpZ#aMR7az^E{3up>8M4bQKM3oq-LTf#(c}-ZPejZ~?(lKm zd-a)?tqrZv;1C`Dh$qcQ_D$FZ?Ahh|1aY`{Kvevme*?SMEwU|LI)_zN+soH8<9NAx zW{-Mi7)_pg%r(LOz&3gU!_?B?a>Do}aH>o|}2+QniZ2=65=qYR4;d5n(1gdqoPinVV~f+y=BB{pejrxnl)`n8nCc zQ^=-|#J3ZD7K?$EFv=Rcyw5*}uWbAuAz`rnc7vcc{E@*%MoR$fBSt&b7shB}-)L51kx@Wl3?ce zoIyUx)9S5<33S0b{n4zQIKEc@;gIZajV#xHJtn)qv;NB=**}qNb!-?Jt6%Cn8E>KMfC74LU|DkW!tUYia{ZQ7#h z>YtD%uM&BUNQKBxLDIqp4;!iz2UuZs+9;X`R251rd5dIzPUHF+KwjS~oFSx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`o2}N!2 zQT3j|j3q78d>%KOg2|1w)nJmW!;o%_3af^gZ|TOTbqf^hdC`u4j{F|0FPh%82o38C zl!<_c88}b_ZKI-XIZW876w5Z_cPW#8*cFo' + matter+=hin + return matter + \ No newline at end of file diff --git a/sch/updater.py b/sch/updater.py new file mode 100644 index 0000000..c20c001 --- /dev/null +++ b/sch/updater.py @@ -0,0 +1,33 @@ +import requests +import json +import time +import os + +try: + os.environ['TZ']='Asia/Kolkata' + time.tzset() +except Exception as e: + pass + +def RefreshJson(): + res=requests.get("https://sagraecdnems05.cdnsrv.jio.com/jiotv.data.cdn.jio.com/apis/v1.3/getMobileChannelList/get/?langId=6&os=android&devicetype=phone&usergroup=tvYR7NSNn7rymo3F&version=6.0.8&langId=6").json() + chnl={} + for i in res['result']: + chnl[i["channel_name"].replace("+"," ")]={"id":i["channel_id"],"lang":i["channelLanguageId"],"cate":i["channelCategoryId"]} + chnl["Updated-on"]=time.strftime("%D-%T") + with open("channel.json","w") as f: + f.write(json.dumps(chnl)) + res=requests.get("http://sjpurecdnems05.cdnsrv.jio.com/jiotv.data.cdn.jio.com/apis/v1.3/dictionary/?langId=6&langId=6") + res=json.loads(res.text[1:]) + chnlCate={} + for i in res['channelCategoryMapping']: + chnlCate[res['channelCategoryMapping'][i]]=int(i) + chnlLang={} + for i in res['languageIdMapping']: + chnlLang[res['languageIdMapping'][i]]=int(i) + with open("categories.json","w") as f: + f.write(json.dumps({"categories":chnlCate,"languages":chnlLang})) + +RefreshJson() + +