mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Fixing three youtube issues: broken usernames/urls (non-uploads), 404 pages, and over-expanding content due to fixvid.
This commit is contained in:
parent
bdd12cf2ee
commit
dabd81608d
1 changed files with 12 additions and 2 deletions
|
@ -131,10 +131,17 @@ class FetchFeed:
|
|||
|
||||
def fetch_youtube(self, address):
|
||||
try:
|
||||
username = re.search('gdata.youtube.com/feeds/\w+/users/(\w+)/uploads', address).group(1)
|
||||
username_groups = re.search('gdata.youtube.com/feeds/\w+/users/(\w+)/uploads', address)
|
||||
if not username_groups:
|
||||
return
|
||||
username = username_groups.group(1)
|
||||
except IndexError:
|
||||
return
|
||||
|
||||
video_ids_xml = requests.get("https://www.youtube.com/feeds/videos.xml?user=%s" % username)
|
||||
if video_ids_xml.status_code != 200:
|
||||
return
|
||||
|
||||
video_ids_soup = BeautifulSoup(video_ids_xml.content)
|
||||
video_ids = []
|
||||
for video_id in video_ids_soup.findAll('yt:videoid'):
|
||||
|
@ -160,11 +167,14 @@ class FetchFeed:
|
|||
thumbnail = video['snippet']['thumbnails'].get('high')
|
||||
if not thumbnail:
|
||||
thumbnail = video['snippet']['thumbnails'].get('medium')
|
||||
content = """<div class="NB-youtube-player">%s</div><br>%s<br><img src="%s" style="display:none" />""" % (
|
||||
content = """<div class="NB-youtube-player">%s</div>
|
||||
<div class="NB-youtube-description">%s</div>
|
||||
<img src="%s" style="display:none" />""" % (
|
||||
video['player']['embedHtml'],
|
||||
linebreaks(video['snippet']['description']),
|
||||
thumbnail['url'] if thumbnail else "",
|
||||
)
|
||||
|
||||
link = "http://www.youtube.com/watch?v=%s&feature=youtube_gdata" % video['id']
|
||||
story_data = {
|
||||
'title': video['snippet']['title'],
|
||||
|
|
Loading…
Add table
Reference in a new issue