Hide posts older than 15 days in main feed
This commit is contained in:
parent
022bf2d5ff
commit
71b3bb6f0c
@ -56,7 +56,7 @@ def twitter():
|
|||||||
else:
|
else:
|
||||||
profilePic = posts[0].userProfilePic
|
profilePic = posts[0].userProfilePic
|
||||||
print("--- {} seconds fetching twitter feed---".format(time.time() - start_time))
|
print("--- {} seconds fetching twitter feed---".format(time.time() - start_time))
|
||||||
return render_template('twitter.html', title='Home', posts=posts, avatar=avatarPath, profilePic = profilePic, followedCount=followCount, form=form)
|
return render_template('twitter.html', title='Parasitter | Twitter', posts=posts, avatar=avatarPath, profilePic = profilePic, followedCount=followCount, form=form)
|
||||||
|
|
||||||
@app.route('/savePost/<url>', methods=['POST'])
|
@app.route('/savePost/<url>', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
@ -64,13 +64,13 @@ def savePost(url):
|
|||||||
savedUrl = url.replace('~', '/')
|
savedUrl = url.replace('~', '/')
|
||||||
r = requests.get(savedUrl)
|
r = requests.get(savedUrl)
|
||||||
html = BeautifulSoup(str(r.content), "lxml")
|
html = BeautifulSoup(str(r.content), "lxml")
|
||||||
post = html.body.find_all('div', attrs={'class':'tweet-content'})
|
post = html.body.find('div', attrs={'class':'main-tweet'})
|
||||||
|
|
||||||
newPost = Post()
|
newPost = Post()
|
||||||
newPost.url = savedUrl
|
newPost.url = savedUrl
|
||||||
newPost.body = html.body.find_all('div', attrs={'class':'main-tweet'})[0].find_all('div', attrs={'class':'tweet-content'})[0].text.encode('latin1').decode('unicode_escape').encode('latin1').decode('utf8')
|
newPost.username = post.find('a','username').text.replace("@","")
|
||||||
newPost.username = html.body.find('a','username').text.replace("@","")
|
newPost.body = post.find_all('div', attrs={'class':'tweet-content'})[0].text.encode('latin1').decode('unicode_escape').encode('latin1').decode('utf8')
|
||||||
newPost.timestamp = html.body.find_all('p', attrs={'class':'tweet-published'})[0].text
|
newPost.timestamp = post.find_all('p', attrs={'class':'tweet-published'})[0].text.encode('latin1').decode('unicode_escape').encode('latin1').decode('utf8')
|
||||||
newPost.user_id = current_user.id
|
newPost.user_id = current_user.id
|
||||||
try:
|
try:
|
||||||
db.session.add(newPost)
|
db.session.add(newPost)
|
||||||
@ -194,7 +194,7 @@ def youtube():
|
|||||||
if videos:
|
if videos:
|
||||||
videos.sort(key=lambda x: x.date, reverse=True)
|
videos.sort(key=lambda x: x.date, reverse=True)
|
||||||
print("--- {} seconds fetching youtube feed---".format(time.time() - start_time))
|
print("--- {} seconds fetching youtube feed---".format(time.time() - start_time))
|
||||||
return render_template('youtube.html', videos=videos, followCount=followCount)
|
return render_template('youtube.html', title="Parasitter | Youtube", videos=videos, followCount=followCount)
|
||||||
|
|
||||||
@app.route('/ytfollowing', methods=['GET', 'POST'])
|
@app.route('/ytfollowing', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
@ -583,6 +583,11 @@ def getYoutubePosts(ids):
|
|||||||
resp = future.result()
|
resp = future.result()
|
||||||
rssFeed=feedparser.parse(resp.content)
|
rssFeed=feedparser.parse(resp.content)
|
||||||
for vid in rssFeed.entries:
|
for vid in rssFeed.entries:
|
||||||
|
time = datetime.datetime.now() - datetime.datetime(*vid.published_parsed[:6])
|
||||||
|
|
||||||
|
if time.days >= 15:
|
||||||
|
continue
|
||||||
|
|
||||||
video = ytPost()
|
video = ytPost()
|
||||||
video.date = vid.published_parsed
|
video.date = vid.published_parsed
|
||||||
video.timeStamp = getTimeDiff(vid.published_parsed)
|
video.timeStamp = getTimeDiff(vid.published_parsed)
|
||||||
|
Reference in New Issue
Block a user