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

How can I make a Funimation extractor? #7742

Closed
Slyneth opened this issue Dec 3, 2015 · 2 comments
Closed

How can I make a Funimation extractor? #7742

Slyneth opened this issue Dec 3, 2015 · 2 comments

Comments

@Slyneth
Copy link

@Slyneth Slyneth commented Dec 3, 2015

Hi.

Being able to use Funimation with youtube-dl would be great for me. So I want to make a extractor. I looked around, checked the source files and learned how to stream Funimation videos directly with mpv, but I couldn't manage to turn it into an extractor. So, if I tell you how I stream them with mpv, could you direct me to some documents and similar extractors to help me make an extractor? I really want to learn how to do this.

First, we need to login, this is the login page: http://funimation.com/login

After that, I check the source with Safari (Chrome doesn't work). I need two things from there:

  • Urls of the video files are inside sdUrl, hdUrl and hd1080Url, like this: "hdUrl":"http://wpc.8c48.edgecastcdn.net/008C48/SV/480/SMSJPNFnsWOM0009/SMSJPNFnsWOM0009-480-2500K.mp4"
  • I need to add authentication, it is inside authToken, like this: "authToken":"?_skA34K7sIi4Wljm1pMBYY414j2jM59Izki1n0KGJ1j65ZR_rVKhNfHimFWkY39ZLKR0jvQzQ4vSESEOn6HWXIOBQoi92KzKbu-j4F1wZCQptSjXCEopf1KFuEx9jrv0ju76Sk2M"

Adding authToken after mp4 nets me the streamable and downloadable file. Everything is the same with all streams except SMSJPNIAGvce0008 part. This is an id consisting of show title (SMS), language (JPN), id (IAGvce) and episode number (0008).

Address of the video is this, by the way: http://www.funimation.com/shows/shomin-sample/videos/official/kagurazaka-sama-is-here?watch=sub

So, how can I create an extractor starting from this information?

Thanks.

@Slyneth
Copy link
Author

@Slyneth Slyneth commented Dec 4, 2015

I have managed to download the streams. But I still can't handle the login process, I am using a cookie. Any help there?

# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import sanitized_Request

import re

class FunimationIE(InfoExtractor):
    _VALID_URL = r'(?P<address>https?://(?:www\.)?funimation\.com/shows/.*/videos/official/.+\=\w+)'
    _USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/601.2.7 (KHTML, like Gecko) Version/9.0.1 Safari/601.2.7'

    def _real_extract(self, url):
    mobj = re.match(self._VALID_URL, url)

    request = sanitized_Request(url)
    request.add_header('User-Agent', self._USER_AGENT)

    video_address = mobj.group('address')
    webpage = self._download_webpage(request, video_address)

    self.report_extraction(video_address)

    video_base = self._search_regex(r'"hdUrl":"(.+?)(?:-2500K.mp4)"', webpage, u'video_base')
    video_id  = self._search_regex(r'"FUNImationID":"(.+?)"', webpage, u'video_id')
    video_auth = self._search_regex(r'"authToken":"(.+?)"', webpage, u'video_auth')  

    video_base = video_base.replace('\\', '')

    formats = [{
        'format_id': 'low',
        'quality': 1,
        'resolution': '480p',
        'url': video_base + '-1500K.mp4' + video_auth,
    }, {
        'format_id': 'high',
        'quality': 2,
        'resolution': '720p',
        'url': video_base + '-2500K.mp4' + video_auth,
    }, {
        'format_id': 'highest',
        'quality': 3, 
        'resolution': '1080p',
        'url': video_base + '-4000K.mp4' + video_auth,
    }]
    self._sort_formats(formats)

    return [{
        'id':        video_id,
        'ext':       'mp4',
        'title':     self._og_search_title(webpage),
        'formats':   formats
    }]  
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Dec 5, 2015

FYI: login functionality is implemented in _login(). Values passed to --username and --password can be retrieved from self._get_login_info(). See vimeo.py and twitch.py for some examples.

Also, it's bad to have two open issues for the same website, so I'm closing this one.

@yan12125 yan12125 closed this Dec 5, 2015
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.