Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Syng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christoph Stahl
Syng
Commits
b37dd9f7
Commit
b37dd9f7
authored
8 months ago
by
Christoph Stahl
Browse files
Options
Downloads
Patches
Plain Diff
Fixed ytsearch a bit more and fixed missing metainfo for direct yt links
parent
838f91d4
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
syng/sources/youtube.py
+7
-6
7 additions, 6 deletions
syng/sources/youtube.py
with
7 additions
and
6 deletions
syng/sources/youtube.py
+
7
−
6
View file @
b37dd9f7
...
@@ -57,7 +57,7 @@ class YouTube:
...
@@ -57,7 +57,7 @@ class YouTube:
return
return
if
self
.
_infos
is
None
:
if
self
.
_infos
is
None
:
raise
RuntimeError
(
f
'
Extraction not possible for
"
{
url
}
"'
)
raise
RuntimeError
(
f
'
Extraction not possible for
"
{
url
}
"'
)
self
.
length
=
self
.
_infos
[
"
duration
"
]
self
.
length
=
int
(
self
.
_infos
[
"
duration
"
]
)
self
.
_title
=
self
.
_infos
[
"
title
"
]
self
.
_title
=
self
.
_infos
[
"
title
"
]
self
.
_author
=
self
.
_infos
[
"
channel
"
]
self
.
_author
=
self
.
_infos
[
"
channel
"
]
self
.
watch_url
=
url
self
.
watch_url
=
url
...
@@ -129,9 +129,11 @@ class Search:
...
@@ -129,9 +129,11 @@ class Search:
:param channel: The channel to search in.
:param channel: The channel to search in.
:type channel: Optional[str]
:type channel: Optional[str]
"""
"""
sp
=
"
EgIQAQ==
"
# This is a magic string, that tells youtube to search for videos
sp
=
"
EgIQA
fABA
Q==
"
# This is a magic string, that tells youtube to search for videos
if
channel
is
None
:
if
channel
is
None
:
query_url
=
f
"
https://youtube.com/results?
{
urlencode
(
{
'
search_query
'
:
query
}
)
}
"
query_url
=
(
f
"
https://youtube.com/results?
{
urlencode
(
{
'
search_query
'
:
query
,
'
sp
'
:
sp
}
)
}
"
)
else
:
else
:
if
channel
[
0
]
==
"
/
"
:
if
channel
[
0
]
==
"
/
"
:
channel
=
channel
[
1
:]
channel
=
channel
[
1
:]
...
@@ -142,7 +144,7 @@ class Search:
...
@@ -142,7 +144,7 @@ class Search:
results
=
YoutubeDL
(
results
=
YoutubeDL
(
{
{
"
extract_flat
"
:
True
,
"
extract_flat
"
:
True
,
"
quiet
"
:
Fals
e
,
"
quiet
"
:
Tru
e
,
"
playlist_items
"
:
"
,
"
.
join
(
map
(
str
,
range
(
1
,
51
))),
"
playlist_items
"
:
"
,
"
.
join
(
map
(
str
,
range
(
1
,
51
))),
}
}
).
extract_info
(
).
extract_info
(
...
@@ -377,8 +379,7 @@ class YoutubeSource(Source):
...
@@ -377,8 +379,7 @@ class YoutubeSource(Source):
Video metadata should be read on the client to avoid banning
Video metadata should be read on the client to avoid banning
the server.
the server.
"""
"""
if
entry
.
incomplete_data
:
if
entry
.
incomplete_data
or
None
in
(
entry
.
artist
,
entry
.
title
):
print
(
f
"
Looking up
{
entry
.
ident
}
"
)
youtube_video
:
YouTube
=
await
asyncio
.
to_thread
(
YouTube
,
entry
.
ident
)
youtube_video
:
YouTube
=
await
asyncio
.
to_thread
(
YouTube
,
entry
.
ident
)
return
{
return
{
"
duration
"
:
youtube_video
.
length
,
"
duration
"
:
youtube_video
.
length
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment