jackyzy823 / rajiko

A tool for unblocking geolocation restriction of radiko.jp!
The Unlicense
211 stars 24 forks source link

Bypassing geo-restriction for share links as well #1

Closed fireattack closed 3 years ago

fireattack commented 3 years ago

Currently, rajiko bypasses geo-restriction on live streaming page and timeshift links http://radiko.jp/#!/ts/*. However, it doesn't handle /share/ links like https://radiko.jp/share/?sid=QRR&t=20210306210000 . So if your IP is not in Japan, it would block you.

Is it possible to bypass geo-check for these links too?

Or, which probably easier is that we can just make them redirect to /ts/ links directly

https://radiko.jp/share/?sid=QRR&t=20210306210000 ---> https://radiko.jp/#!/ts/QRR/20210306210000

(The only thing to notice is /share/ links typically use 29-hour format while /ts/ ones only accept 24-hour. So links past 0:00 such as https://radiko.jp/share/?sid=QRR&t=20210306260000 should be converted to https://radiko.jp/#!/ts/QRR/20210307020000 instead.

https://radiko.jp/#!/ts/QRR/20210306260000 is still "valid", but is the wrong/different program.)

andykamezou commented 3 years ago

Are you sure you didn't just click a wrong shared URL? Because I've been using my own "share to ts converter" UserScript. The script literally just convert share to ts URL format, and it worked just fine for me.

And I just checked, the shared URL for MOMO・SORA・SHIINA Talking Box is https://radiko.jp/share/?sid=QRR&t=20210307020000 . I get the correct timestamp (20210307020000), from outside Japan, without VPN or any time conversion.

Or did you use any extension that change your browser time? Because I remember using something like that and it messing up radiko timetable.

fireattack commented 3 years ago

And I just checked, the shared URL for MOMO・SORA・SHIINA Talking Box is https://radiko.jp/share/?sid=QRR&t=20210307020000 . I get the correct timestamp (20210307020000), from outside Japan, without VPN or any time conversion.

/share/ links support both 29-hour format and 24-hour format.

https://radiko.jp/share/?sid=QRR&t=20210306260000 https://radiko.jp/share/?sid=QRR&t=20210307020000

Both are valid and will redirect you to https://radiko.jp/#!/ts/QRR/20210307020000 (if you're in Japan). (Actually, it supports more than 29-hour, anything after 24:00 (or even 48:00) would be redirected to correct 24-hour format just fine: https://radiko.jp/share/?sid=QRR&t=20210306400000 (40:00!) --> https://radiko.jp/#!/ts/QRR/20210307160000 )

And the official link does use 29-hour format one:

>curl http://www.joqr.co.jp/timefree/mss.php
<!DOCTYPE html>
<html lang="ja">
        <head>
                <meta charset="utf-8">
                <title>
                        radiko リダイレクト
                </title>
                <script type="text/javascript" src="/_common/js/ul.js"></script>
                <script type="text/javascript" src="/_common/js/ga.js"></script>
                <META HTTP-EQUIV="Refresh" CONTENT="1; URL=http://radiko.jp/share/?sid=QRR&t=20210306260000">
        </head>
        <body>
                Waiting radiko ...
        </body>
</html>
fireattack commented 3 years ago

Oh, you probably get the link from share button on Radiko. That one indeed uses 24-hour format. Mine is from their official Twitter. Most of 文化放送 programs have such /timefree/ shortcuts (like http://www.joqr.co.jp/timefree/agson.php etc.)

Anyway, both are valid.

andykamezou commented 3 years ago

https://radiko.jp/share/?sid=QRR&t=20210306260000 https://radiko.jp/share/?sid=QRR&t=20210307020000

Ok now I clearly understand what you mean.

I just checked on VM with Tokyo VPN. When radiko detect user from Japan, 20210306260000 will be redirected to 20210307020000. But outside Japan 20210306260000 will go directly to 20210306260000 (which is a different program).

Haven't research much about radiko in recent years since I know about the existence rajiko, so I'm not aware of this~

Good thing the "real" timestamp also included in the js in share page. So if Jacky decide not to continue updating rajiko, atleast we can just use this as a reference to redirect with UserScript.

//from https://radiko.jp/share/?sid=QRR&t=20210306260000&noreload=1
    var get_share_log_url = function(params) {
        params.station = "QRR";
        params.t = "20210307020000";
        params.device = "pc";
        // キャッシュ対策
        params._ =  Math.floor(Math.random() * 1000000);

        var param_str = "";
        $.each(params, function(key, val){
            param_str += "&" + key + "=" + val;
        });
        var url = "https://beacon.radiko.jp/share.gif";
        return url + param_str.replace(/^./,"?");
    };
fireattack commented 3 years ago

It's probably more accurate to say that if you're outside Japan, /share/ link will literally block you than it redirects you to the wrong time. Basically any link will just redirect to same address and add &noreload=1 (to prevent redirect loop), and show you something like

image

That part about time format is more a side note saying "if want to implement it by redirect share to ts ourselves, we should be careful about time format conversion blabla".

Yeah I agree it's pretty trivial to write a userscript yourself and bypass it. Just think it would be a nice inclusion for rajiko since it already bypasses geo-restriction on any other URLs.

jackyzy823 commented 3 years ago

Thanks for reporting @fireattack @andykamezou

Will work on this , maybe this weekend or next...

Some ideas just to avoid that i forget: use content scriptto determine whether we are blocked and send message with url from get_share_log_url (from share page's script) to background and parse it and use chrome.tabs.update to redirect to correct url

jackyzy823 commented 3 years ago

I uploaded v0.2.6 to Chrome Web Store. Waiting for Chrome Web Store's review. Or you could load extension from source code.