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

GenericIE: New flashplayer case: config file (solution inside) #735

Closed
maximeg opened this issue Mar 8, 2013 · 1 comment
Closed

GenericIE: New flashplayer case: config file (solution inside) #735

maximeg opened this issue Mar 8, 2013 · 1 comment

Comments

@maximeg
Copy link

@maximeg maximeg commented Mar 8, 2013

As @phihag fixed a previous bug report #734 using :

webpage = self._download_webpage(url, video_id)

it made me think about a case.

Test case:
http://www.nokenny.com/comment-ne-pas-casser-une-table.html

This webpage contains :

...
<embed src="http://www.nokenny.com/player.swf" width="100%" height="400" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" flashvars="config=http://www.nokenny.com/v/comment-ne-pas-casser-une-table&image=&logo=&displayclick=play&autostart=1&plugins=fbit-1,tweetit-1&controlbar=bottom&frontcolor=&lightcolor=&backcolor=FFFFFF"></embed>
...

And the config file (http://www.nokenny.com/v/comment-ne-pas-casser-une-table) contains :

<?xml version="1.0" encoding="ISO-8859-1"?> <config>
    <file>http://www.nokenny.com/FLV/upload_flv/video_15644_1343987924.flv</file>            
    <image>http://www.nokenny.com/FLV/upload/4tuhqtrv.jpg</image>            
    <link>http://www.nokenny.com/comment-ne-pas-casser-une-table.html</link>
    <displayclick>link</displayclick>
    <linktarget>_blank</linktarget>
    <title>Comment ne pas casser une table</title>     
    <autostart>false</autostart>
    <bufferlength>3</bufferlength>
    <type>video</type>
    <task>frontpage</task>            
    <dock>true</dock>     
    <plugins>sharing-3</plugins>
    <sharing.code>&lt;div&gt;&lt;embed src=&quot;http://www.nokenny.com/player.swf&quot; width=&quot;425&quot; height=&quot;344&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; flashvars=&quot;config=http://www.nokenny.com/v/comment-ne-pas-casser-une-table&quot;&gt;
    &lt;/embed&gt;&lt;br /&gt;&lt;a href=&quot;http://www.nokenny.com/comment-ne-pas-casser-une-table.html&quot;&gt;Comment ne pas casser une table&lt;/a&gt; - &lt;a href=&quot;http://www.nokenny.com&quot;&gt;NoKenny&lt;/a&gt;&lt;/div&gt;</sharing.code>
    <sharing.link>http://www.nokenny.com/comment-ne-pas-casser-une-table.html</sharing.link>
    <stretching>uniform</stretching>
    <backcolor>f2f2f2</backcolor>
    <frontcolor>2a2a2a</frontcolor>
    <lightcolor>b11b1b</lightcolor>
    <screencolor>000000</screencolor>
    </config>

Other examples of site using this: http://www.epicfail.com ...

So here the code :

        # Start with something easy: JW Player in SWFObject
        mobj = re.search(r'flashvars: [\'"](?:.*&)?file=(http[^\'"&]*)', webpage)
        if mobj is None:
            # Broaden the search a little bit
            mobj = re.search(r'[^A-Za-z0-9]?(?:file|source)=(http[^\'"&]*)', webpage)
        if mobj is None:
            # Broaden the search a little bit: JWPlayer JS loader
            mobj = re.search(r'[^A-Za-z0-9]?file:\s*["\'](http[^\'"&]*)', webpage)
        if mobj is None:
            # Broaden the search a little bit: Flashplayer calling a config file
            mobj = re.search(r'[^A-Za-z0-9]?config=(http[^\'"&]*)', webpage)
            if mobj is not None:
                config_url = compat_urllib_parse.unquote(mobj.group(1))
                config_page = self._download_webpage(config_url, video_id)
                mobj = re.search(r'<file>\s*(http[^<\s]*)\s*</file>', config_page)
        if mobj is None:
            self._downloader.trouble(u'ERROR: Invalid URL: %s' % url)
            return

Again, I let you evaluate this, my python skills improved by 300% just by writing this :)

@dstftw
Copy link
Collaborator

@dstftw dstftw commented May 8, 2017

Works with latest version.

@dstftw dstftw closed this May 8, 2017
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.