Skip to content

Commit

Permalink
html_common: remove x_item_html functions
Browse files Browse the repository at this point in the history
  • Loading branch information
user234683 committed Feb 27, 2019
1 parent 89daa27 commit 8ceaa34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 52 deletions.
50 changes: 0 additions & 50 deletions youtube/html_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,56 +103,6 @@



# -----
# HTML
# -----

def small_video_item_html(item):
video_info = json.dumps({key: item[key] for key in ('id', 'title', 'author', 'duration')})
return small_video_item_template.substitute(
title = html.escape(item["title"]),
views = item["views"],
author = html.escape(item["author"]),
duration = item["duration"],
url = util.URL_ORIGIN + "/watch?v=" + item["id"],
thumbnail = util.get_thumbnail_url(item['id']),
video_info = html.escape(video_info),
)

def small_playlist_item_html(item):
return small_playlist_item_template.substitute(
title=html.escape(item["title"]),
size = item['size'],
author="",
url = util.URL_ORIGIN + "/playlist?list=" + item["id"],
thumbnail= util.get_thumbnail_url(item['first_video_id']),
)

def medium_playlist_item_html(item):
return medium_playlist_item_template.substitute(
title=html.escape(item["title"]),
size = item['size'],
author=item['author'],
author_url= util.URL_ORIGIN + item['author_url'],
url = util.URL_ORIGIN + "/playlist?list=" + item["id"],
thumbnail= item['thumbnail'],
)

def medium_video_item_html(medium_video_info):
info = medium_video_info

return medium_video_item_template.substitute(
title=html.escape(info["title"]),
views=info["views"],
published = info["published"],
description = yt_data_extract.format_text_runs(info["description"]),
author=html.escape(info["author"]),
author_url=info["author_url"],
duration=info["duration"],
url = util.URL_ORIGIN + "/watch?v=" + info["id"],
thumbnail=info['thumbnail'],
datetime='', # TODO
)


header_template = Template('''
Expand Down
8 changes: 6 additions & 2 deletions youtube/watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ def get_related_items_html(info):
result = ""
for item in info['related_vids']:
if 'list' in item: # playlist:
result += html_common.small_playlist_item_html(watch_page_related_playlist_info(item))
item = watch_page_related_playlist_info(item)
result += html_common.playlist_item_html(item, html_common.small_playlist_item_template)
else:
result += html_common.small_video_item_html(watch_page_related_video_info(item))
item = watch_page_related_video_info(item)
result += html_common.video_item_html(item, html_common.small_video_item_template)
return result


Expand All @@ -142,6 +144,7 @@ def watch_page_related_video_info(item):
result['views'] = item['short_view_count_text']
except KeyError:
result['views'] = ''
result['thumbnail'] = util.get_thumbnail_url(item['id'])
return result

def watch_page_related_playlist_info(item):
Expand All @@ -150,6 +153,7 @@ def watch_page_related_playlist_info(item):
'title': item['playlist_title'],
'id': item['list'],
'first_video_id': item['video_id'],
'thumbnail': util.get_thumbnail_url(item['video_id']),
}


Expand Down

0 comments on commit 8ceaa34

Please sign in to comment.