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.
|
||||
# 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(payload)
|
||||
break
|
||||
y=y+1
|
||||
|
||||
feedImport()
|
||||
feedImport()
|
||||
|
||||
60
main.py
60
main.py
@@ -146,38 +146,38 @@ def addFeed():
|
||||
db.session.add(query)
|
||||
count = count + 1
|
||||
db.session.commit()
|
||||
return jsonify(message='Podcast added')
|
||||
return jsonify(title=title, added=1)
|
||||
else:
|
||||
return jsonify(message='Podcast already exists')
|
||||
return jsonify(title=title, added=0)
|
||||
|
||||
@app.route('/importFeed/', methods=['POST'])
|
||||
def importFeed():
|
||||
|
||||
count = 0
|
||||
data = request.get_json()
|
||||
parsed = fp.parse(data['newURL'])
|
||||
|
||||
title = str(parsed.feed.title)
|
||||
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.
|
||||
# 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():
|
||||
query = podcasts(userID=data['userID'], title=title, URL=data['newURL'], artworkURL=artwork)
|
||||
db.session.add(query)
|
||||
db.session.commit()
|
||||
# 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()
|
||||
# Import the new shows. No need to check if the show URLS already exist since it's new
|
||||
for items in parsed['entries']:
|
||||
itemURL = parsed.entries[count].enclosures[0].get('href')
|
||||
query = shows(podcastID=result.podcastID, userID=data['userID'], link=itemURL)
|
||||
db.session.add(query)
|
||||
count = count + 1
|
||||
db.session.commit()
|
||||
return jsonify(message='Podcast added')
|
||||
else:
|
||||
return jsonify(message='Podcast already exists')
|
||||
# @app.route('/importFeed/', methods=['POST'])
|
||||
# def importFeed():
|
||||
#
|
||||
# count = 0
|
||||
# data = request.get_json()
|
||||
# parsed = fp.parse(data['newURL'])
|
||||
#
|
||||
# title = str(parsed.feed.title)
|
||||
# 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.
|
||||
# # 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():
|
||||
# query = podcasts(userID=data['userID'], title=title, URL=data['newURL'], artworkURL=artwork)
|
||||
# db.session.add(query)
|
||||
# db.session.commit()
|
||||
# # 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()
|
||||
# # Import the new shows. No need to check if the show URLS already exist since it's new
|
||||
# for items in parsed['entries']:
|
||||
# itemURL = parsed.entries[count].enclosures[0].get('href')
|
||||
# query = shows(podcastID=result.podcastID, userID=data['userID'], link=itemURL)
|
||||
# db.session.add(query)
|
||||
# count = count + 1
|
||||
# db.session.commit()
|
||||
# return jsonify(message='Podcast added')
|
||||
# else:
|
||||
# return jsonify(message='Podcast already exists')
|
||||
|
||||
|
||||
@app.route('/listPodcasts/<int:userID>/', methods=['GET'])
|
||||
|
||||
Reference in New Issue
Block a user