8 Commits
0.2.5 ... 0.2.6

Author SHA1 Message Date
Jesus
6011a08cdf v0.2.6 2023-09-11 04:20:49 +08:00
Jesus
83af4ab0d7 Fix comment count not extracted sometimes
YouTube created a new key 'commentCount' in addition to 'headerText'
2023-09-11 04:15:25 +08:00
Jesus
5594d017e2 Fix related vids, like_count, playlist sometimes missing
Cause is that some pages have the onResponseReceivedEndpoints key
at the top level with useless stuff in it, and the extract_items
function was searching in that instead of the 'contents' key.

Change to use if blocks instead of elif blocks in the
extract_items function.
2023-09-11 04:13:56 +08:00
Jesus
8f9c5eeb48 Fix 403s 1 minute into videos
https://github.com/iv-org/invidious/issues/4027
https://github.com/TeamNewPipe/NewPipeExtractor/pull/1084/files
2023-09-11 04:08:23 +08:00
Jesus
89e21302e3 generate_release.py: fix syntax error 2023-09-11 04:07:15 +08:00
Jesus
cb4ceefada Filter out translated audio tracks
See comment in code
2023-09-11 04:06:11 +08:00
Jesus E
c4cc5cecbf README.md: update 2023-06-19 21:38:05 -04:00
Jesus E
cc8f30eba2 Relax error and send error_code to template 2023-06-19 21:23:25 -04:00
8 changed files with 43 additions and 16 deletions

View File

@@ -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

View File

@@ -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'

View File

@@ -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 = {

View File

@@ -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" %}

View File

@@ -1,3 +1,3 @@
from __future__ import unicode_literals
__version__ = '0.2.5'
__version__ = '0.2.6'

View File

@@ -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))

View File

@@ -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(

View File

@@ -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