-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[peertube] Added extractor #16329
[peertube] Added extractor #16329
Conversation
youtube_dl/extractor/peertube.py
Outdated
_BASE_THUMBNAIL_URL = 'https://peertube.touhoppai.moe/static/previews/%s.jpg' | ||
IE_DESC = 'Peertube Videos' | ||
IE_NAME = 'Peertube' | ||
_VALID_URL = r'https?:\/\/peertube\.touhoppai\.moe\/videos\/watch\/(?P<id>[0-9|\-|a-z]+)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which line in particular are you referring to as invalid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exact line, namely the capture group.
youtube_dl/extractor/peertube.py
Outdated
|
||
|
||
class PeertubeIE(InfoExtractor): | ||
_BASE_VIDEO_URL = 'https://peertube.touhoppai.moe/static/webseed/%s-1080.mp4' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No hardcodes. Use API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which api are you talking about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Website's API.
youtube_dl/extractor/peertube.py
Outdated
'ext': 'mp4', | ||
'title': 'David Revoy Live Stream: Speedpainting', | ||
'description': 'md5:5c09a6e3fdb5f56edce289d69fbe7567', | ||
'thumbnail': 'https://peertube.touhoppai.moe/static/previews/7f3421ae-6161-4a4a-ae38-d167aec51683.jpg', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relax.
689c980
to
2d8fc9c
Compare
@dstftw please review |
youtube_dl/extractor/peertube.py
Outdated
class PeertubeIE(InfoExtractor): | ||
IE_DESC = 'Peertube Videos' | ||
IE_NAME = 'Peertube' | ||
_VALID_URL = r'https?:\/\/peertube\.touhoppai\.moe\/videos\/watch\/(?P<id>[0-9|\-|a-z]+)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is exactly wrong with the capture group as it seems correct to me and runs without any errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code in bracket is a set of matching characters. or
ing won't work.
youtube_dl/extractor/extractors.py
Outdated
@@ -1332,7 +1333,7 @@ | |||
WebOfStoriesPlaylistIE, | |||
) | |||
from .weibo import ( | |||
WeiboIE, | |||
WeiboIE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all unrelated changes.
youtube_dl/extractor/peertube.py
Outdated
def _real_extract(self, url): | ||
video_id = self._match_id(url) | ||
url_data = compat_urlparse.urlparse(url) | ||
api_url = "%s://%s/api/v1/videos/%s" % (url_data.scheme, url_data.hostname, video_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urljoin
.
youtube_dl/extractor/peertube.py
Outdated
return { | ||
'id': video_id, | ||
'title': details['name'], | ||
'description': details['description'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not break if missing.
youtube_dl/extractor/peertube.py
Outdated
'id': video_id, | ||
'title': details['name'], | ||
'description': details['description'], | ||
'url': details['files'][-1]['fileUrl'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All formats must be extracted.
youtube_dl/extractor/peertube.py
Outdated
'title': details['name'], | ||
'description': details['description'], | ||
'url': details['files'][-1]['fileUrl'], | ||
'thumbnail': url_data.scheme + '://' + url_data.hostname + details['thumbnailPath'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
896568a
to
45c7e97
Compare
@dstftw Made the required changes. Please review. |
youtube_dl/extractor/peertube.py
Outdated
class PeertubeIE(InfoExtractor): | ||
IE_DESC = 'Peertube Videos' | ||
IE_NAME = 'Peertube' | ||
_VALID_URL = r'https?:\/\/peertube\.touhoppai\.moe\/videos\/watch\/(?P<id>[0-9|a-z]{8}-[0-9|a-z]{4}-[0-9|a-z]{4}-[0-9|a-z]{4}-[0-9|a-z]{12})' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you read my messages at all?
youtube_dl/extractor/peertube.py
Outdated
video_id = self._match_id(url) | ||
url_data = compat_urlparse.urlparse(url) | ||
base_url = "%s://%s" % (url_data.scheme, url_data.hostname) | ||
api_url = urljoin(urljoin(base_url, "/api/v1/videos/"), video_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What the hell are you doing? urljoin(url, '/api/v1/videos/%s' % video_id)
. All.
youtube_dl/extractor/peertube.py
Outdated
details = self._download_json(api_url, video_id) | ||
return { | ||
'id': video_id, | ||
'title': details.get('name'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read: coding conventions, mandatory fields.
youtube_dl/extractor/peertube.py
Outdated
'title': details.get('name'), | ||
'description': details.get('description'), | ||
'formats': [{'url': file_data['fileUrl'], 'filesize': file_data.get('size')} for file_data in sorted(details['files'], key=lambda x: x['size'])], | ||
'thumbnail': urljoin(base_url, details['thumbnailPath']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read: coding conventions, optional fields.
youtube_dl/extractor/peertube.py
Outdated
'id': video_id, | ||
'title': details.get('name'), | ||
'description': details.get('description'), | ||
'formats': [{'url': file_data['fileUrl'], 'filesize': file_data.get('size')} for file_data in sorted(details['files'], key=lambda x: x['size'])], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_sort_formats
.- Must not break if any of these keys is missing.
@dstftw Made the changes. Please verify. |
youtube_dl/extractor/peertube.py
Outdated
video_id = self._match_id(url) | ||
url_data = compat_urlparse.urlparse(url) | ||
base_url = "%s://%s" % (url_data.scheme, url_data.hostname) | ||
api_url = urljoin(base_url, "/api/v1/videos/%s" % video_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you trolling or what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AGAIN Can you please be more descriptive!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've provided clear working piece of code that you must just copy paste. Instead you introduced mess with base URL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did just copy that😐. The change with the base url is incase the url is received with no scheme defined
youtube_dl/extractor/peertube.py
Outdated
'duration': details.get('duration'), | ||
'view_count': details.get('views'), | ||
'like_count': details.get('likes'), | ||
'dislike_count': details.get('dislikes'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int_or_none
.
youtube_dl/extractor/peertube.py
Outdated
'thumbnail': urljoin(base_url, details['thumbnailPath']) if 'thumbnailPath' in details else None, | ||
'uploader': details.get('account', {}).get('name'), | ||
'uploader_id': details.get('account', {}).get('id'), | ||
'uploder_url': details.get('account', {}).get('url'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try_get
.
youtube_dl/extractor/peertube.py
Outdated
class PeertubeIE(InfoExtractor): | ||
IE_DESC = 'Peertube Videos' | ||
IE_NAME = 'Peertube' | ||
_VALID_URL = r'(?:https?:)//peertube\.touhoppai\.moe\/videos\/watch\/(?P<id>[0-9|a-z]{8}-[0-9|a-z]{4}-[0-9|a-z]{4}-[0-9|a-z]{4}-[0-9|a-z]{12})' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please be more descriptive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read my previous comments. I'm not going to repeat myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regex is appropriate as the id is always in uuid format which follows the exact same format and the values are hex code so though a-z should be replaced by a-f i believe the rest of the format will remain the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You: [0-9|a-f]
. Stackoverflow: [0-9a-f]
. Difference? You have to learn to distinguish (...)
and [...]
.
@h-h-h-h made the changes, check now. |
Please follow the guide below
x
into all the boxes [ ] relevant to your pull request (like that [x])Before submitting a pull request make sure you have:
In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
Description of your pull request and other information
Adds the ability to download videos from peertube.touhoppai.moe thus resolving #16301