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

Site Support Request: Funimation #6614

Closed
ghost opened this issue Aug 19, 2015 · 11 comments
Closed

Site Support Request: Funimation #6614

ghost opened this issue Aug 19, 2015 · 11 comments
Labels
site-support-request Add extractor(s) for a new domain

Comments

@ghost
Copy link

ghost commented Aug 19, 2015

I was wondering if it was possible to add Funimation support.

The video info is stored in the source code.

The actual video URL:
http://wpc.8c48.edgecastcdn.net/008C48/SV/480/[FUNIMATIONID]/[FUNIMATIONID]-480-[BITRATE]K.mp4[AUTHTOKEN]

So for: http://www.funimation.com/shows/blood-blockade-battlefront/videos/official/secret-society-of-the-magic-sealed-city?watch=dub

A search forFUNImationID returns "FUNImationID":"BLOENG0001"}

The bitrates are only viewable in the source with a Funimation Subscription.

"sdUrl":"http:\/\/wpc.8c48.edgecastcdn.net\/008C48\/SV\/480\/BLOENG0001\/BLOENG0001-480-1500K.mp4"
"hdUrl":"http:\/\/wpc.8c48.edgecastcdn.net\/008C48\/SV\/480\/BLOENG0001\/BLOENG0001-480-2500K.mp4"
"hd1080Url":"http:\/\/wpc.8c48.edgecastcdn.net\/008C48\/SV\/480\/BLOENG0001\/BLOENG0001-480-4000K.mp4"

They only show three in the player, but they're seem to be more:1000,1500,2000,2500,3500,4000

1000=480p [1.13 Mbit/s]
1500=480p [1.64 Mbit/s]
2000=480p [2.14 Mbit/s]
2500=720p [2.64 Mbit/s]
3500=720p [3.64 Mbit/s]
4000=1080p [4.16 Mbit/s][BEST]

^^Although I'm not entirely sure how they handle 360p for older videos^^

Then a search for authToken returns "authToken":"?OfCIkqEfAeub4cSbxSXwgu-a4BwthcLD8HbsUFFOLsu6TeZ93nz-8AGMuLcgN6Ieo5tPi7uAuFNDonRJgCdx7iUPU0DPPZrbThGPovMXsK-rUQV5K5GOKp4uSBkPJ_9sXlJ1fkFqXosWBxH0x4f6"

They're is actually two different authTokens in the source, but they both seem to do the same.

So finally you're left with http://wpc.8c48.edgecastcdn.net/008C48/SV/480/BLOENG0001/BLOENG0001-480-4000K.mp4?OfCIkqEfAeub4cSbxSXwgu-a4BwthcLD8HbsUFFOLsu6TeZ93nz-8AGMuLcgN6Ieo5tPi7uAuFNDonRJgCdx7iUPU0DPPZrbThGPovMXsK-rUQV5K5GOKp4uSBkPJ_9sXlJ1fkFqXosWBxH0x4f6

@dstftw
Copy link
Collaborator

dstftw commented Aug 19, 2015

It's for subscribers only.

@ghost
Copy link
Author

ghost commented Aug 19, 2015

The only info really needed is FUNImationID, and authToken.
Then plug them into:

wpc.8c48.edgecastcdn.net/008C48/SV/480/[FUNImationID]/[FUNImationID]-480-2000K.mp4[authToken] - for 480p
wpc.8c48.edgecastcdn.net/008C48/SV/480/[FUNImationID]/[FUNImationID]-480-3500K.mp4[authToken] - for 720p
wpc.8c48.edgecastcdn.net/008C48/SV/480/[FUNImationID]/[FUNImationID]-480-4000K.mp4[authToken] - for 1080p

Both FUNImationID, and authToken, can be found in the HTML page source.
With or without a Funimation subscription.
FUNImationID can return two matches:

"FUNImationID":"XXXENG####" - English Dubbed
"FUNImationID":"XXXJPN####" - English Subbed

XXX = Show specific ID.
#### = Episode Number. 0001-9999

@ghost
Copy link
Author

ghost commented Sep 6, 2015

@Slyneth
Copy link

Slyneth commented Nov 29, 2015

Any plans about this?

@jaimeMF jaimeMF added the site-support-request Add extractor(s) for a new domain label Nov 29, 2015
@Slyneth
Copy link

Slyneth commented Dec 4, 2015

#7742

@Slyneth
Copy link

Slyneth commented Dec 5, 2015

Alright, things are moving along. The scripts logins, recognizes three formats, downloads the one you want.

I have this problems and I am stuck with my limited knowledge (I didn't know anything at all 3 days ago). So, I need direction =)

Firstly; even if everything works, it keeps giving me this: WARNING: Extractor Funimation returned a compat_list result. It needs to be updated. I have no idea what this is.

Secondly; it logins (I even got it to say that logining is mandatory) but when wrong login information is given it just errors out. I want it to give a message saying login information was wrong. There is no videos you can use without login, it send to Hulu if you try that. But there are free videos.

Thirdly; tests doesn't work. It needs to login but tests gives me this: AttributeError: 'module' object has no attribute '--username'

This is the script:

# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
    sanitized_Request,
    ExtractorError,
    urlencode_postdata,
)

import re

class FunimationBaseIE(InfoExtractor):
    _NETRC_MACHINE = 'funimation'
    _LOGIN_REQUIRED = True

    def _login(self):
        (username, password) = self._get_login_info()
    if username is None:
            if self._LOGIN_REQUIRED:
                raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True)
            return
        self.report_login()
        login_url = 'http://www.funimation.com/login'
        data = urlencode_postdata({
            'formname': 'loginForm2',
            'email_field': username,
            'password_field': password,
        })
        login_request = sanitized_Request(login_url, data)
        login_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
        self._download_webpage(login_request, None, False, login_url)

    def _real_initialize(self):
        self._login()

class FunimationIE(FunimationBaseIE):
    _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'

    _TEST = {
        'url': 'http://www.funimation.com/shows/shomin-sample/videos/official/kagurazaka-sama-is-here?watch=sub',
        'md5': '1d2840927cc587901a7ae4062666a3aa',
        'info_dict': {
            'id': 'SMSJPNFnsWOM0009',
            'ext': 'mp4',
            'title': 'Shomin Sample - Kagurazaka-sama is Here',
        }
    }

    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, 'video_base')
    video_id  = self._search_regex(r'"FUNImationID":"(.+?)"', webpage, 'video_id')
    video_auth = self._search_regex(r'"authToken":"(.+?)"', webpage, '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
        }]

Thanks for all your help!

@yan12125
Copy link
Collaborator

yan12125 commented Dec 5, 2015

@Slyneth Could you open a pull request?

By the way, for a single video just return:

        return {
            'id':        video_id,
            'ext':       'mp4',
            'title':     self._og_search_title(webpage),
        'formats':   formats
        }

Also, identation in your codes looks wrong. Have you tested it with both Python 2.x and Python 3.x?

@Slyneth
Copy link

Slyneth commented Dec 5, 2015

Yes, spaces and tabs are wrong all over, but I just discovers flake8, I will fix it tonight. And make the test with a free to watch video (that one is subs only).

I don't have Python 3, I will test it.

I will make the pull request tonight, after fixing those.

Thanks.

@Slyneth
Copy link

Slyneth commented Dec 5, 2015

Right now it works with Python 2 and 3. compat_list warning got fixed by itself, I don't how. Only problem is the test, I can't get it to work with login. Should I push like this?

Also this only works with the new videos (all simulcasts work), most of their archive is on Hulu. Is there a way to say this in a message?

This is final, working code:

# coding: utf-8
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (sanitized_Request, ExtractorError, urlencode_postdata)

import re

class FunimationBaseIE(InfoExtractor):
    _LOGIN_REQUIRED = True

    def _login(self):
        (username, password) = self._get_login_info()
        if username is None:
                if self._LOGIN_REQUIRED:
                    raise ExtractorError('No login info available, needed for using %s.' % self.IE_NAME, expected=True)
                return
        self.report_login()
        login_url = 'http://www.funimation.com/login'
        data = urlencode_postdata({
            'formname': 'loginForm2',
            'email_field': username,
            'password_field': password,
        })
        login_request = sanitized_Request(login_url, data)
        login_request.add_header('Content-Type', 'application/x-www-form-urlencoded')
        self._download_webpage(login_request, login_url)

    def _real_initialize(self):
        self._login()

class FunimationIE(FunimationBaseIE):
    _VALID_URL = r'(?P<address>https?://(?:www\.)?funimation\.com/shows/.*/videos/official/.+)'
    _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, 'video_base')
        video_id = self._search_regex(r'"FUNImationID":"(.+?)"', webpage, 'video_id')
        video_auth = self._search_regex(r'"authToken":"(.+?)"', webpage, 'video_auth')

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

        formats = [{
            'format_id': 'lowest',
            'quality': 1,
            'resolution': '480p',
            'url': video_base + '-1000K.mp4' + video_auth,
        }, {
            'format_id': 'lower',
            'quality': 2,
            'resolution': '480p',
            'url': video_base + '-1500K.mp4' + video_auth,
        }, {
            'format_id': 'low',
            'quality': 3,
            'resolution': '480p',
            'url': video_base + '-2000K.mp4' + video_auth,
        }, {
            'format_id': 'medium',
            'quality': 4,
            'resolution': '720p',
            'url': video_base + '-2500K.mp4' + video_auth,
        }, {
            'format_id': 'high',
            'quality': 5,
            'resolution': '720p',
            'url': video_base + '-3500K.mp4' + video_auth,
        }, {
            'format_id': 'highest',
            'quality': 6,
            '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
        }

Thanks.

@yan12125
Copy link
Collaborator

yan12125 commented Dec 5, 2015

For testing _login, fc2.py can be a good example. Just specifying 'username' and 'password' in 'params'. Don't forget to remove the actual password add a 'skip' line before commit.

For Hulu videos, it's OK to raise a ExtractorError with expected=True. Note that Hulu.com support hasn't reach the first stesp yet. See #1629.

@dstftw
Copy link
Collaborator

dstftw commented Jan 15, 2016

Funimation is supported for quite some time already.

@dstftw dstftw closed this as completed Jan 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
site-support-request Add extractor(s) for a new domain
Projects
None yet
Development

No branches or pull requests

4 participants