Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6011a08cdf | ||
|
|
83af4ab0d7 | ||
|
|
5594d017e2 | ||
|
|
8f9c5eeb48 | ||
|
|
89e21302e3 | ||
|
|
cb4ceefada | ||
|
|
c4cc5cecbf | ||
|
|
cc8f30eba2 |
@@ -153,7 +153,7 @@ For coding guidelines and an overview of the software architecture, see the [HAC
|
||||
|
||||
yt-local is not made to work in public mode, however there is an instance of yt-local in public mode but with less features
|
||||
|
||||
- <https://06ff-93-95-230-133.ngrok-free.app/https://www.youtube.com/>
|
||||
- <https://1cd1-93-95-230-133.ngrok-free.app/https://youtube.com>
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ if len(sys.argv) > 2:
|
||||
else:
|
||||
bitness = '64'
|
||||
|
||||
if latest_version = 'oldwin':
|
||||
if latest_version == 'oldwin':
|
||||
bitness = '32'
|
||||
latest_version = '3.7.9'
|
||||
suffix = 'windows-vista-7-only'
|
||||
|
||||
@@ -115,7 +115,18 @@ def error_page(e):
|
||||
error_message=exc_info()[1].error_message,
|
||||
slim=slim
|
||||
), 502)
|
||||
return flask.render_template('error.html', traceback=traceback.format_exc(), slim=slim), 500
|
||||
elif (exc_info()[0] == util.FetchError
|
||||
and exc_info()[1].code == '404'
|
||||
):
|
||||
error_message = ('Error: The page you are looking for isn\'t here. ¯\_(ツ)_/¯')
|
||||
return flask.render_template('error.html',
|
||||
error_code=exc_info()[1].code,
|
||||
error_message=error_message,
|
||||
slim=slim), 404
|
||||
return flask.render_template('error.html', traceback=traceback.format_exc(),
|
||||
error_code=exc_info()[1].code,
|
||||
slim=slim), 500
|
||||
# return flask.render_template('error.html', traceback=traceback.format_exc(), slim=slim), 500
|
||||
|
||||
|
||||
font_choices = {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{% set page_title = 'Error' %}
|
||||
{% if error_code %}
|
||||
{% set page_title = 'Error: ' ~ error_code %}
|
||||
{% else %}
|
||||
{% set page_title = 'Error' %}
|
||||
{% endif %}
|
||||
|
||||
{% if not slim %}
|
||||
{% extends "base.html" %}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
__version__ = '0.2.5'
|
||||
__version__ = '0.2.6'
|
||||
|
||||
@@ -396,7 +396,7 @@ def fetch_player_response(client, video_id):
|
||||
data = {
|
||||
'videoId': video_id,
|
||||
'context': context,
|
||||
'params': '8AEB',
|
||||
'params': 'CgIQBg',
|
||||
}
|
||||
data = json.dumps(data)
|
||||
headers = (('Content-Type', 'application/json'),('User-Agent', user_agent))
|
||||
|
||||
@@ -109,7 +109,7 @@ def concat_or_none(*strings):
|
||||
def remove_redirect(url):
|
||||
if url is None:
|
||||
return None
|
||||
if re.fullmatch(r'(((https?:)?//)?(www.)?youtube.com)?/redirect\?.*', url) is not None: # youtube puts these on external links to do tracking
|
||||
if re.fullmatch(r'(((https?:)?//)?(www.)?youtube.com)?/redirect\?.*', url) is not None: # YouTube puts these on external links to do tracking
|
||||
query_string = url[url.find('?')+1: ]
|
||||
return urllib.parse.parse_qs(query_string)['q'][0]
|
||||
return url
|
||||
@@ -133,11 +133,11 @@ def _recover_urls(runs):
|
||||
for run in runs:
|
||||
url = deep_get(run, 'navigationEndpoint', 'urlEndpoint', 'url')
|
||||
text = run.get('text', '')
|
||||
# second condition is necessary because youtube makes other things into urls, such as hashtags, which we want to keep as text
|
||||
# second condition is necessary because YouTube makes other things into urls, such as hashtags, which we want to keep as text
|
||||
if url is not None and (text.startswith('http://') or text.startswith('https://')):
|
||||
url = remove_redirect(url)
|
||||
run['url'] = url
|
||||
run['text'] = url # youtube truncates the url text, use actual url instead
|
||||
run['text'] = url # YouTube truncates the url text, use actual url instead
|
||||
|
||||
def extract_str(node, default=None, recover_urls=False):
|
||||
'''default is the value returned if the extraction fails. If recover_urls is true, will attempt to fix YouTube's truncation of url text (most prominently seen in descriptions)'''
|
||||
@@ -569,13 +569,13 @@ def extract_items(response, item_types=_item_types,
|
||||
item_types=item_types)
|
||||
if items:
|
||||
break
|
||||
elif ('onResponseReceivedEndpoints' in response
|
||||
if ('onResponseReceivedEndpoints' in response
|
||||
or 'onResponseReceivedActions' in response):
|
||||
for endpoint in multi_get(response,
|
||||
'onResponseReceivedEndpoints',
|
||||
'onResponseReceivedActions',
|
||||
[]):
|
||||
items, ctoken = extract_items_from_renderer_list(
|
||||
new_items, new_ctoken = extract_items_from_renderer_list(
|
||||
multi_deep_get(
|
||||
endpoint,
|
||||
['reloadContinuationItemsCommand', 'continuationItems'],
|
||||
@@ -584,13 +584,17 @@ def extract_items(response, item_types=_item_types,
|
||||
),
|
||||
item_types=item_types,
|
||||
)
|
||||
if items:
|
||||
break
|
||||
elif 'contents' in response:
|
||||
items += new_items
|
||||
if (not ctoken) or (new_ctoken and new_items):
|
||||
ctoken = new_ctoken
|
||||
if 'contents' in response:
|
||||
renderer = get(response, 'contents', {})
|
||||
items, ctoken = extract_items_from_renderer(
|
||||
new_items, new_ctoken = extract_items_from_renderer(
|
||||
renderer,
|
||||
item_types=item_types)
|
||||
items += new_items
|
||||
if (not ctoken) or (new_ctoken and new_items):
|
||||
ctoken = new_ctoken
|
||||
|
||||
if search_engagement_panels and 'engagementPanels' in response:
|
||||
new_items, new_ctoken = extract_items_from_renderer_list(
|
||||
|
||||
@@ -357,7 +357,8 @@ def _extract_watch_info_mobile(top_level):
|
||||
# https://www.androidpolice.com/2019/10/31/google-youtube-app-comment-section-below-videos/
|
||||
# https://www.youtube.com/watch?v=bR5Q-wD-6qo
|
||||
if header_type == 'commentsEntryPointHeaderRenderer':
|
||||
comment_count_text = extract_str(comment_info.get('headerText'))
|
||||
comment_count_text = extract_str(multi_get(
|
||||
comment_info, 'commentCount', 'headerText'))
|
||||
else:
|
||||
comment_count_text = extract_str(deep_get(comment_info,
|
||||
'header', 'commentSectionHeaderRenderer', 'countText'))
|
||||
@@ -463,6 +464,13 @@ def _extract_formats(info, player_response):
|
||||
for yt_fmt in yt_formats:
|
||||
itag = yt_fmt.get('itag')
|
||||
|
||||
# Translated audio track
|
||||
# Example: https://www.youtube.com/watch?v=gF9kkB0UWYQ
|
||||
# Only get the original language for now so a foreign
|
||||
# translation will not be picked just because it comes first
|
||||
if deep_get(yt_fmt, 'audioTrack', 'audioIsDefault') is False:
|
||||
continue
|
||||
|
||||
fmt = {}
|
||||
fmt['itag'] = itag
|
||||
fmt['ext'] = None
|
||||
|
||||
Reference in New Issue
Block a user