Tweaks
This commit is contained in:
@@ -18,10 +18,9 @@ def feedImport ():
|
|||||||
|
|
||||||
#checks to see if the podcast URL already exists for logged in user and skips it if it has already been imported.
|
#checks to see if the podcast URL already exists for logged in user and skips it if it has already been imported.
|
||||||
# payload = '''{"userid" : 1, "newURL": "''' + str(url) + '''"}'''
|
# payload = '''{"userid" : 1, "newURL": "''' + str(url) + '''"}'''
|
||||||
r = requests.post(API_URL+'/addFeed', json={"userID" : 1, "newURL" : url})
|
r = requests.post(API_URL+'/addFeed/', json={"userID" : 1, "newURL" : url})
|
||||||
print(r.text)
|
print(r.text)
|
||||||
# print(payload)
|
# print(payload)
|
||||||
break
|
|
||||||
y=y+1
|
y=y+1
|
||||||
|
|
||||||
feedImport()
|
feedImport()
|
||||||
60
main.py
60
main.py
@@ -146,38 +146,38 @@ def addFeed():
|
|||||||
db.session.add(query)
|
db.session.add(query)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
return jsonify(message='Podcast added')
|
return jsonify(title=title, added=1)
|
||||||
else:
|
else:
|
||||||
return jsonify(message='Podcast already exists')
|
return jsonify(title=title, added=0)
|
||||||
|
|
||||||
@app.route('/importFeed/', methods=['POST'])
|
# @app.route('/importFeed/', methods=['POST'])
|
||||||
def importFeed():
|
# def importFeed():
|
||||||
|
#
|
||||||
count = 0
|
# count = 0
|
||||||
data = request.get_json()
|
# data = request.get_json()
|
||||||
parsed = fp.parse(data['newURL'])
|
# parsed = fp.parse(data['newURL'])
|
||||||
|
#
|
||||||
title = str(parsed.feed.title)
|
# title = str(parsed.feed.title)
|
||||||
artwork = str(parsed.feed.image)
|
# artwork = str(parsed.feed.image)
|
||||||
|
#
|
||||||
# checks to see if the podcast URL already exists for logged in user and skips it if it has already been imported.
|
# # checks to see if the podcast URL already exists for logged in user and skips it if it has already been imported.
|
||||||
# if the show doesn't already exist for the logged in user it gets added
|
# # if the show doesn't already exist for the logged in user it gets added
|
||||||
if not podcasts.query.filter_by(URL=data['newURL'], userID=data['userID']).first():
|
# if not podcasts.query.filter_by(URL=data['newURL'], userID=data['userID']).first():
|
||||||
query = podcasts(userID=data['userID'], title=title, URL=data['newURL'], artworkURL=artwork)
|
# query = podcasts(userID=data['userID'], title=title, URL=data['newURL'], artworkURL=artwork)
|
||||||
db.session.add(query)
|
# db.session.add(query)
|
||||||
db.session.commit()
|
# db.session.commit()
|
||||||
# Once the podcast is added we grab the podcastID so we can import the shows
|
# # Once the podcast is added we grab the podcastID so we can import the shows
|
||||||
result = podcasts.query.filter_by(URL=data['newURL'], userID=data['userID']).first()
|
# result = podcasts.query.filter_by(URL=data['newURL'], userID=data['userID']).first()
|
||||||
# Import the new shows. No need to check if the show URLS already exist since it's new
|
# # Import the new shows. No need to check if the show URLS already exist since it's new
|
||||||
for items in parsed['entries']:
|
# for items in parsed['entries']:
|
||||||
itemURL = parsed.entries[count].enclosures[0].get('href')
|
# itemURL = parsed.entries[count].enclosures[0].get('href')
|
||||||
query = shows(podcastID=result.podcastID, userID=data['userID'], link=itemURL)
|
# query = shows(podcastID=result.podcastID, userID=data['userID'], link=itemURL)
|
||||||
db.session.add(query)
|
# db.session.add(query)
|
||||||
count = count + 1
|
# count = count + 1
|
||||||
db.session.commit()
|
# db.session.commit()
|
||||||
return jsonify(message='Podcast added')
|
# return jsonify(message='Podcast added')
|
||||||
else:
|
# else:
|
||||||
return jsonify(message='Podcast already exists')
|
# return jsonify(message='Podcast already exists')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/listPodcasts/<int:userID>/', methods=['GET'])
|
@app.route('/listPodcasts/<int:userID>/', methods=['GET'])
|
||||||
|
|||||||
Reference in New Issue
Block a user