Skip to content
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

Thumbnail of Hotstar.com videos #17600

Closed
GourangaDas opened this issue Sep 18, 2018 · 1 comment
Closed

Thumbnail of Hotstar.com videos #17600

GourangaDas opened this issue Sep 18, 2018 · 1 comment
Labels

Comments

@GourangaDas
Copy link

@GourangaDas GourangaDas commented Sep 18, 2018

Hi!
Currently, youtube-dl doesn't provide the link of thumbnail of hotstar.com videos.

I've found a way to get thumbnail url by modifying the code 'hotstar.py'

Here's the code of '_real_extract(self, url)' as below. Please consider to check it out.

def _real_extract(self, url):
        video_id = self._match_id(url)

        video_data = self._download_content_info(video_id)

        # here I will try to get thubnail image from webpage
        page = self._download_webpage(url, video_id)
        thumbUrl = self._og_search_thumbnail(page)
        
        title = video_data.get('contentTitle')
        if video_data.get('encrypted') == 'Y':
            raise ExtractorError('This video is DRM protected.', expected=True)

        formats = []
        for f in ('JIO',):
            format_data = self._download_json(
                'http://getcdn.hotstar.com/AVS/besc',
                video_id, 'Downloading %s JSON metadata' % f,
                fatal=False, query={
                    'action': 'GetCDN',
                    'asJson': 'Y',
                    'channel': f,
                    'id': video_id,
                    'type': 'VOD',
                })
            if format_data:
                format_url = format_data.get('src')
                if not format_url:
                    continue
                ext = determine_ext(format_url)
                if ext == 'm3u8':
                    formats.extend(self._extract_m3u8_formats(
                        format_url, video_id, 'mp4',
                        m3u8_id='hls', fatal=False))
                elif ext == 'f4m':
                    # produce broken files
                    continue
                else:
                    formats.append({
                        'url': format_url,
                        'width': int_or_none(format_data.get('width')),
                        'height': int_or_none(format_data.get('height')),
                    })
        self._sort_formats(formats)
        return {
            'id': video_id,
            'description': video_data.get('description'),
            'duration': int_or_none(video_data.get('duration')),
            'timestamp': int_or_none(video_data.get('broadcastDate')),
            'formats': formats,
            'episode': title,
            'episode_number': int_or_none(video_data.get('episodeNumber')),
            'series': video_data.get('contentTitle'),
            'title': title,
            'thumbnail': thumbUrl
        }

@remitamine
Copy link
Collaborator

@remitamine remitamine commented Sep 18, 2018

for instuction on how to contribute code look at https://github.com/rg3/youtube-dl#developer-instructions.
Duplicate of #16079.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.