mirror of
https://github.com/neosubhamoy/pytubepp.git
synced 2025-12-20 02:19:35 +05:30
(feat): added full raw stream listing useful for debugging and minor improvements
This commit is contained in:
@@ -103,6 +103,7 @@ pytubepp "https://youtube.com/watch?v=2lAe1cqCOXo" -i
|
|||||||
| -s | Choose preferred download stream | YES | YES | `144` `144p` `240` `240p` `360` `360p` `480` `480p` `720` `720p` `hd` `1080` `1080p` `fhd` `1440` `1440p` `2k` `2160` `2160p` `4k` `4320` `4320p` `8k` `mp3` (Pass any one of them) | Your chosen Default Stream via `-ds` flag |
|
| -s | Choose preferred download stream | YES | YES | `144` `144p` `240` `240p` `360` `360p` `480` `480p` `720` `720p` `hd` `1080` `1080p` `fhd` `1440` `1440p` `2k` `2160` `2160p` `4k` `4320` `4320p` `8k` `mp3` (Pass any one of them) | Your chosen Default Stream via `-ds` flag |
|
||||||
| -c | Choose preferred caption | YES | YES | All [ISO 639-1 Language Codes](https://www.w3schools.com/tags/ref_language_codes.asp) + some others (Pass any one of them) eg: `en` for English | Your chosen Default Caption via `-dc` flag |
|
| -c | Choose preferred caption | YES | YES | All [ISO 639-1 Language Codes](https://www.w3schools.com/tags/ref_language_codes.asp) + some others (Pass any one of them) eg: `en` for English | Your chosen Default Caption via `-dc` flag |
|
||||||
| -i | Shows the video information like: Title, Author, Views, Publication Date, Duration, Available Download Streams | NO | YES | No parameters | No default |
|
| -i | Shows the video information like: Title, Author, Views, Publication Date, Duration, Available Download Streams | NO | YES | No parameters | No default |
|
||||||
|
| -ls | Lists all available streams (video, audio, caption) (only for debuging purposes) | NO | YES | No parameters | No default |
|
||||||
| -ri | Shows the video information in raw json format | NO | YES | No parameters | No default |
|
| -ri | Shows the video information in raw json format | NO | YES | No parameters | No default |
|
||||||
| -jp | Shows raw json output in prettified view (with indentation: 4) (primarily used with -ri flag)| NO | YES | No parameters | No default |
|
| -jp | Shows raw json output in prettified view (with indentation: 4) (primarily used with -ri flag)| NO | YES | No parameters | No default |
|
||||||
| -ds | Set default download stream | YES | NO | `144p` `240p` `360p` `480p` `720p` `1080p` `1440p` `2160p` `4320p` `mp3` `max` (Pass any one of them) | `max` |
|
| -ds | Set default download stream | YES | NO | `144p` `240p` `360p` `480p` `720p` `1080p` `1440p` `2160p` `4320p` `mp3` `max` (Pass any one of them) | `max` |
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class YouTubeDownloader:
|
|||||||
|
|
||||||
if is_valid_url(link):
|
if is_valid_url(link):
|
||||||
link = is_valid_url(link).group(1)
|
link = is_valid_url(link).group(1)
|
||||||
self.video = YouTube(link, 'ANDROID', on_progress_callback=progress)
|
self.video = YouTube(link, on_progress_callback=progress)
|
||||||
self.author = self.video.author
|
self.author = self.video.author
|
||||||
self.title = re.sub(r'[\\/*?:"<>|]', '_', self.author + ' - ' + self.video.title)
|
self.title = re.sub(r'[\\/*?:"<>|]', '_', self.author + ' - ' + self.video.title)
|
||||||
self.thumbnail = self.video.thumbnail_url
|
self.thumbnail = self.video.thumbnail_url
|
||||||
@@ -152,6 +152,24 @@ class YouTubeDownloader:
|
|||||||
else:
|
else:
|
||||||
print('\nInvalid video link! Please enter a valid video url...!!')
|
print('\nInvalid video link! Please enter a valid video url...!!')
|
||||||
|
|
||||||
|
def show_all_streams(self, link):
|
||||||
|
if self.set_video_info(link):
|
||||||
|
print(f"Available Streams({len(self.stream)}):")
|
||||||
|
if self.stream:
|
||||||
|
for stream in self.stream:
|
||||||
|
print(stream)
|
||||||
|
else:
|
||||||
|
print('No stream available!')
|
||||||
|
|
||||||
|
print(f"\nAvailable Captions({len(self.captions)}):")
|
||||||
|
if self.captions:
|
||||||
|
for caption in self.captions:
|
||||||
|
print(caption)
|
||||||
|
else:
|
||||||
|
print('No caption available!')
|
||||||
|
else:
|
||||||
|
print('\nInvalid video link! Please enter a valid video url...!!')
|
||||||
|
|
||||||
def show_raw_info(self, link, prettify=False):
|
def show_raw_info(self, link, prettify=False):
|
||||||
if self.set_video_info(link):
|
if self.set_video_info(link):
|
||||||
streams_list = []
|
streams_list = []
|
||||||
@@ -315,8 +333,9 @@ def main():
|
|||||||
parser.add_argument('-ds', '--default-stream', default=argparse.SUPPRESS, help='set default download stream (default: max) [available arguments: 144p, 240p, 360p, 480p, 720p, 1080p, 1440p, 2160p, 4320p, mp3, max]')
|
parser.add_argument('-ds', '--default-stream', default=argparse.SUPPRESS, help='set default download stream (default: max) [available arguments: 144p, 240p, 360p, 480p, 720p, 1080p, 1440p, 2160p, 4320p, mp3, max]')
|
||||||
parser.add_argument('-dc', '--default-caption', default=argparse.SUPPRESS, help='set default caption (default: none) [available arguments: all language codes, none]')
|
parser.add_argument('-dc', '--default-caption', default=argparse.SUPPRESS, help='set default caption (default: none) [available arguments: all language codes, none]')
|
||||||
parser.add_argument('-s', '--stream', default=argparse.SUPPRESS, help='choose download stream for the current video (default: your chosen --default-stream) [available arguments: 144p, 240p, 360p, 480p, 720p, 1080p, 1440p, 2160p, 4320p, 144, 240, 360, 480, 720, 1080, 1440, 2160, 4320, mp3, hd, fhd, 2k, 4k, 8k]')
|
parser.add_argument('-s', '--stream', default=argparse.SUPPRESS, help='choose download stream for the current video (default: your chosen --default-stream) [available arguments: 144p, 240p, 360p, 480p, 720p, 1080p, 1440p, 2160p, 4320p, 144, 240, 360, 480, 720, 1080, 1440, 2160, 4320, mp3, hd, fhd, 2k, 4k, 8k]')
|
||||||
parser.add_argument('-c', '--caption', default=argparse.SUPPRESS, help='choose caption to embed for the current video (default: none)')
|
parser.add_argument('-c', '--caption', default=argparse.SUPPRESS, help='choose caption to embed for the current video (default: your chosen --default-caption) [available arguments: all language codes, none]')
|
||||||
parser.add_argument('-i', '--show-info', action='store_true', help='show video info (title, author, views and available_streams)')
|
parser.add_argument('-i', '--show-info', action='store_true', help='show video info (title, author, views and available_streams)')
|
||||||
|
parser.add_argument('-ls', '--list-stream', action='store_true', help='list all available streams (video, audio, caption) (only for debuging purposes)')
|
||||||
parser.add_argument('-ri', '--raw-info', action='store_true', help='show video info in raw json format')
|
parser.add_argument('-ri', '--raw-info', action='store_true', help='show video info in raw json format')
|
||||||
parser.add_argument('-jp', '--json-prettify', action='store_true', help='show json in prettified indented view')
|
parser.add_argument('-jp', '--json-prettify', action='store_true', help='show json in prettified indented view')
|
||||||
parser.add_argument('-sc', '--show-config', action='store_true', help='show all current user config settings')
|
parser.add_argument('-sc', '--show-config', action='store_true', help='show all current user config settings')
|
||||||
@@ -352,6 +371,8 @@ def main():
|
|||||||
# Handle info display flags
|
# Handle info display flags
|
||||||
if args.show_info:
|
if args.show_info:
|
||||||
downloader.show_video_info(args.url)
|
downloader.show_video_info(args.url)
|
||||||
|
if args.list_stream:
|
||||||
|
downloader.show_all_streams(args.url)
|
||||||
if args.raw_info:
|
if args.raw_info:
|
||||||
downloader.show_raw_info(args.url, args.json_prettify)
|
downloader.show_raw_info(args.url, args.json_prettify)
|
||||||
if args.json_prettify and not args.raw_info:
|
if args.json_prettify and not args.raw_info:
|
||||||
@@ -433,7 +454,7 @@ def main():
|
|||||||
print('Download cancelled! exiting...!!')
|
print('Download cancelled! exiting...!!')
|
||||||
else:
|
else:
|
||||||
print('Sorry, No downloadable video stream found....!!!')
|
print('Sorry, No downloadable video stream found....!!!')
|
||||||
elif not any([args.show_info, args.raw_info, args.json_prettify]): # If no info flags are set
|
elif not any([args.show_info, args.raw_info, args.json_prettify, args.list_stream]): # If no info flags are set
|
||||||
if downloader.set_video_info(args.url):
|
if downloader.set_video_info(args.url):
|
||||||
if downloader.default_stream == 'max' and downloader.maxres:
|
if downloader.default_stream == 'max' and downloader.maxres:
|
||||||
if downloader.default_caption == 'none':
|
if downloader.default_caption == 'none':
|
||||||
@@ -546,6 +567,9 @@ def main():
|
|||||||
if args.show_info:
|
if args.show_info:
|
||||||
print('\nNo video url supplied! exiting...!!')
|
print('\nNo video url supplied! exiting...!!')
|
||||||
|
|
||||||
|
if args.list_stream:
|
||||||
|
print('\nNo video url supplied! exiting...!!')
|
||||||
|
|
||||||
if args.raw_info:
|
if args.raw_info:
|
||||||
print('\nNo video url supplied! exiting...!!')
|
print('\nNo video url supplied! exiting...!!')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user