Files

42 lines
1.3 KiB
Python
Raw Permalink Normal View History

2021-02-21 00:30:49 -06:00
from xml.dom.minidom import Document, Element
2021-05-31 15:35:32 -05:00
import xml.dom.minidom as xml
2021-02-21 00:30:49 -06:00
from flask import Flask, request, Response
import musicbrainzngs
from atom.factory import *
2021-03-20 23:55:33 -05:00
from locale import *
locale = getdefaultlocale()[0]
2021-04-17 16:46:34 -05:00
2021-02-21 00:30:49 -06:00
app = Flask(__name__)
2021-05-31 15:35:32 -05:00
musicbrainzngs.set_useragent("Zune", "4.8", "https://github.com/yoshiask/PyZuneCommerceServer")
2021-02-21 00:30:49 -06:00
2021-05-31 15:56:46 -05:00
@app.route(f"/v2/<string:locale>/account/signin", methods=['POST'])
def account_signin(locale: str):
2021-05-31 16:04:19 -05:00
try:
print(request.data)
signinReq: Document = xml.parseString(request.data.decode('utf-8'))
tunerInfo: Element = signinReq.firstChild
idElem: Element = tunerInfo.getElementsByTagName("ID")[0]
nameElem: Element = tunerInfo.getElementsByTagName("Name")[0]
typeElem: Element = tunerInfo.getElementsByTagName("Type")[0]
versionElem: Element = tunerInfo.getElementsByTagName("Version")[0]
id: str = idElem.firstChild.data
2021-05-31 16:04:19 -05:00
doc: Document = minidom.Document()
feed: Element = create_feed(doc, "album_name", "album_id", request.endpoint)
2021-02-21 00:30:49 -06:00
2021-05-31 16:04:19 -05:00
# doc.appendChild(feed)
xml_str = doc.toprettyxml(indent="\t")
return Response(xml_str, mimetype=MIME_XML)
except Exception as e:
import traceback
return Response(traceback.format_exc(), status=500, mimetype="text/plain")
2021-02-21 00:30:49 -06:00
2021-05-31 15:35:32 -05:00
if __name__ == "__main__":
app.run(port=443)