Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
Fix yotter data import
Browse files Browse the repository at this point in the history
  • Loading branch information
pluja committed Nov 6, 2020
1 parent 0454c71 commit 92689b9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,22 +363,23 @@ def ytfollow(channelId):

def followYoutubeChannel(channelId):
try:
channelData = YoutubeSearch.channelInfo(channelId, False)
try:
if not current_user.is_following_yt(channelId):
channelData = ytch.get_channel_tab_info(channelId, tab='about')
if channelData == False:
return False
follow = youtubeFollow()
follow.channelId = channelId
follow.channelName = channelData[0]['name']
follow.channelName = channelData['channel_name']
follow.followers.append(current_user)
db.session.add(follow)
db.session.commit()
flash("{} followed!".format(channelData[0]['name']))
flash("{} followed!".format(channelData['channel_name']))
return True
else:
return False
except Exception as e:
print(e)
flash("Youtube: Couldn't follow {}. Already followed?".format(channelData[0]['name']))
return False
except KeyError as ke:
print("KeyError: {}:'{}' could not be found".format(ke, channelId))
Expand Down Expand Up @@ -686,6 +687,7 @@ def importdata():
flash('No selected file')
return redirect(request.referrer)
else:
flash("Data is being imported. You can keep using Yotter.")
importdataasync(file)
return redirect(request.referrer)

Expand Down Expand Up @@ -885,7 +887,7 @@ def getFeed(urls):
with FuturesSession() as session:
futures = [session.get('{instance}{user}'.format(instance=NITTERINSTANCE, user=u.username)) for u in urls]
for future in as_completed(futures):
res = future.result().content.decode('utf-8')
res= future.result().content
html = BeautifulSoup(res, "html.parser")
userFeed = html.find_all('div', attrs={'class': 'timeline-item'})
if userFeed != []:
Expand Down

0 comments on commit 92689b9

Please sign in to comment.