diff --git a/.gitignore b/.gitignore index ac77d92..947795f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -__* +__pycache__ env venv dist \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 6787402..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# chainetv_web - diff --git a/backend/__init__.py b/backend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/Jsonfile.py b/backend/chainetv/Jsonfile.py similarity index 100% rename from backend/Jsonfile.py rename to backend/chainetv/Jsonfile.py diff --git a/backend/ReverseProxied.py b/backend/chainetv/ReverseProxied.py similarity index 100% rename from backend/ReverseProxied.py rename to backend/chainetv/ReverseProxied.py diff --git a/backend/chainetv/__init__.py b/backend/chainetv/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/backend/chainetv/api.py b/backend/chainetv/api.py new file mode 100644 index 0000000..8383852 --- /dev/null +++ b/backend/chainetv/api.py @@ -0,0 +1,34 @@ +from flask import Blueprint, jsonify, request,make_response,redirect,url_for,render_template +from chainetv.Jsonfile import JSONfile +from chainetv import emission +data= JSONfile("chaine.json") + + +api = Blueprint("api", __name__) +@api.route('/ping', methods=['GET']) +def ping_pong(): + return jsonify('pong!') + +@api.route('/chaine/', methods=['GET']) +def get_chaine(num): + chaine=data.get_chaine(num) + if (chaine == "numero de chaine inconnue"): + return make_response("",204) + else: + return jsonify(chaine) + +@api.route('/chaine/', methods=['put']) +def update_list(): + status=data.parsechaine() + if(status=='ok'): + return jsonify("OK") + else: + return make_response('Error during Chaine Update',500) + +@api.route('/chaine//emission', methods=['GET']) +def get_emmission(num): + chaine=data.get_chaine(num) + if (chaine == "numero de chaine inconnue"): + return make_response("",204) + else: + return jsonify(emission.parse_emmission(chaine)) diff --git a/backend/chainetv/app.py b/backend/chainetv/app.py new file mode 100644 index 0000000..f4a46e6 --- /dev/null +++ b/backend/chainetv/app.py @@ -0,0 +1,21 @@ +from flask import Flask,render_template +from flask_cors import CORS + +#from ReverseProxied import ReverseProxied +def create_app(app_name=__name__): + app=Flask(__name__, static_folder= "../dist/static",template_folder="../dist") + app.config.from_object('chainetv.config.BaseConfig') + #app.wsgi_app = ReverseProxied(app.wsgi_app) + CORS(app) + from chainetv.api import api + app.register_blueprint(api, url_prefix="/api/v1") + @app.route('/') + @app.route('/') + def index(path="/"): + return render_template('index.html') + return app + + +##@app.errorhandler(404) +##def ma_page_404(error): +## return redirect("https://www.ducamps.win/404/404.html", 307) diff --git a/backend/chaine.json b/backend/chainetv/chaine.json similarity index 100% rename from backend/chaine.json rename to backend/chainetv/chaine.json diff --git a/backend/chainetv/config.py b/backend/chainetv/config.py new file mode 100644 index 0000000..24dea4c --- /dev/null +++ b/backend/chainetv/config.py @@ -0,0 +1,3 @@ +class BaseConfig(object): + DEBUG = True + SECRET_KEY = 'mysecretkeyg' \ No newline at end of file diff --git a/backend/emission.py b/backend/chainetv/emission.py similarity index 73% rename from backend/emission.py rename to backend/chainetv/emission.py index fd14d9d..8068e78 100644 --- a/backend/emission.py +++ b/backend/chainetv/emission.py @@ -24,14 +24,22 @@ def parse_emmission(strsearch): html = response.read() parse=BeautifulSoup(html,"html.parser") divcasting=parse.select_one(".descriptif") - casting=divcasting.find_all(href=re.compile("biographie")) - count=0 - for actor in casting: - casting[count]=actor.text - count+=1 + if (divcasting): + casting=divcasting.find_all(href=re.compile("biographie")) + count=0 + for actor in casting: + casting[count]=actor.text + count+=1 + else: + casting= None divsynopsis=parse.select_one(".episode-synopsis") - img=divsynopsis.find_next('img')['data-src'] - synopsis=divsynopsis.select_one(".d-b").text + if (divsynopsis): + img=divsynopsis.find_next('img')['data-src'] + synopsis=divsynopsis.select_one(".d-b").text + else: + img=None + synopsis="" + return {'title':link['title'],'href':href,'casting':casting,'synopsis':remove_first_space(synopsis),'img':img} diff --git a/backend/run.py b/backend/run.py index 8df6d4a..eda0270 100644 --- a/backend/run.py +++ b/backend/run.py @@ -1,52 +1,5 @@ -from flask import Flask,request,make_response,redirect,url_for,render_template,jsonify -from flask_cors import CORS -from Jsonfile import JSONfile -#from ReverseProxied import ReverseProxied -import emission -data= JSONfile("chaine.json") -app=Flask(__name__,static_folder = "./dist/static",template_folder="./dist") -#app.wsgi_app = ReverseProxied(app.wsgi_app) -CORS(app) - -@app.route('/', defaults={'path': ''}) -@app.route('/') -def index(path): - return render_template('index.html') - -@app.route('/api/v1/ping', methods=['GET']) -def ping_pong(): - return jsonify('pong!') - -@app.route('/api/v1/chaine/', methods=['GET']) -def get_chaine(num): - chaine=data.get_chaine(num) - if (chaine == "numero de chaine inconnue"): - return make_response("",204) - else: - return jsonify(chaine) - -@app.route('/api/v1/chaine/', methods=['put']) -def update_list(): - status=data.parsechaine() - if(status=='ok'): - return jsonify("OK") - else: - return make_response('Error during Chaine Update',500) - -@app.route('/api/v1/chaine//emission', methods=['GET']) -def get_emmission(num): - chaine=data.get_chaine(num) - if (chaine == "numero de chaine inconnue"): - return make_response("",204) - else: - return jsonify(emission.parse_emmission(chaine)) - -##@app.errorhandler(404) -##def ma_page_404(error): -## return redirect("https://www.ducamps.win/404/404.html", 307) - - - +from chainetv.app import create_app +app= create_app() if __name__ == '__main__': - app.run(debug=True) \ No newline at end of file + app.run() \ No newline at end of file diff --git a/client/package-lock.json b/client/package-lock.json index c0af77b..e3e8eae 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -11773,6 +11773,11 @@ "integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==", "dev": true }, + "vuex": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/vuex/-/vuex-3.1.0.tgz", + "integrity": "sha512-mdHeHT/7u4BncpUZMlxNaIdcN/HIt1GsGG5LKByArvYG/v6DvHcOxvDCts+7SRdCoIRGllK8IMZvQtQXLppDYg==" + }, "watchpack": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", diff --git a/client/package.json b/client/package.json index cd64562..5dd9825 100644 --- a/client/package.json +++ b/client/package.json @@ -14,7 +14,8 @@ "axios": "^0.18.0", "bulma": "^0.7.4", "vue": "^2.5.2", - "vue-router": "^3.0.1" + "vue-router": "^3.0.1", + "vuex": "^3.1.0" }, "devDependencies": { "autoprefixer": "^7.1.2", diff --git a/client/src/api/index.js b/client/src/api/index.js new file mode 100644 index 0000000..1793707 --- /dev/null +++ b/client/src/api/index.js @@ -0,0 +1,20 @@ +import axios from "axios"; + +const API_PATH=`${process.env.ROOT_API}/api/v1`; + +export function fetchchaine(num){ + + return axios.get(`${API_PATH}/chaine/${num}`) +} + +export function fetchemission(num){ + + return axios.get(`${API_PATH}/chaine/${num}/emission`) + +} + +export function putparsechaine(){ + + return axios.put(`${API_PATH}/chaine/`); + +} \ No newline at end of file diff --git a/client/src/components/chainetv.vue b/client/src/components/chainetv.vue index 37ded3e..72c2b57 100644 --- a/client/src/components/chainetv.vue +++ b/client/src/components/chainetv.vue @@ -29,8 +29,8 @@
-
    -
  • +
      +
    • {{result.chaine}} : {{result.name}}

      • @@ -74,63 +74,34 @@