alzamer2 / Crunchyroll-XML-Decoder-py3

GNU General Public License v3.0
17 stars 5 forks source link

Error : UnboundLocalError on start #1

Closed RGFRv2 closed 5 years ago

RGFRv2 commented 5 years ago

Hello, I launched the.py file, it installed the missing modules but it returns this to me:

python3.6 crunchy-xml-decoder-py3.py

python version=4.9.2 64 bit
OS Version=Linux 3.16.0 4 amd64 x86_64 with debian 8.11
System Type=x86_64
Colorama : installed!
lxml : installed!
wget : installed!
Cryptography : installed!
Cfscrape : installed!
m3u8 : installed!
BeautifulSoup : installed!
pager : installed!
Unidecode : installed!
proxybroker : installed!
Can't find the crunchy-xml-decoder-py3 Folder
Traceback (most recent call last):
  File "crunchy-xml-decoder-py3.py", line 26, in <module>
    testing_external_moudules_()
  File "crunchy-xml-decoder/external_test.py", line 123, in testing_external_moudules_
    if not os.path.exists(bin_dir__):
UnboundLocalError: local variable 'bin_dir__' referenced before assignment

Any solution to solve this?

alzamer2 commented 5 years ago

hi i tried to fix it redownload the code and try it out

alzamer2 commented 5 years ago

give me feedback so I can do other adjustments

RGFRv2 commented 5 years ago

I downloaded the code, it works but it happens to have an error with mkvmerge that wants to install but crashes.

And when we restart, he no longer asks to install mkvmerge.

It is also impossible to download the videos and subtitles of a premium video (Login with a premium account)


---- Downloading Subtitle -----

The video has hardcoded subtitles.

- Free video + subtitles: 
```Python
Booting up....

Please enter Crunchyroll video URL:
http://www.crunchyroll.com/fr/kemono-friends/episode-12-im-home-781660
Now Downloading - Kemono Friends Episode 12 - Finally home!
               787MB/787MB |%100 @ 11.21Mb/s
                Part#136 |%100.0

------------------------------
---- Downloading Subtitle -----
------------------------------
Attempting to download English (US) subtitle....
Attempting to download Español subtitle....
Attempting to download Español (España) subtitle....
Attempting to download العربية subtitle....
Attempting to download Italiano subtitle....
Attempting to download Deutsch subtitle....
Attempting to download Русский subtitle....
Attempting to download French (France) subtitle....
Attempting to download Português (Brasil) subtitle....
Starting mkv merge
Español (España) English (US) English (US) English (US)
Italiano English (US) English (US)
Español English (US) English (US)
English (US) English (US) English (US) English (US)
Français (France) English (US) English (US) English (US) English (US)
العربية English (US) English (US) English (US) English (US)
Português (Brasil) English (US) English (US) English (US) English (US)
Русский English (US) English (US) English (US) English (US)
Deutsch English (US) English (US) English (US) English (US)
English (US)
Traceback (most recent call last):
  File "crunchy-xml-decoder-py3.py", line 378, in <module>
    make_choise()
  File "crunchy-xml-decoder-py3.py", line 329, in make_choise
    ultimate()
  File "crunchy-xml-decoder/ultimate.py", line 209, in ultimate
    mkv_merge(video_input, vquality, "English')
  File "crunchy-xml-decoder/ultimate.py", line 270, in mkv_merge
    subprocess.call(['wine']+cmd)
  File "/usr/local/lib/python3.6/subprocess.py", line 267, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/local/lib/python3.6/subprocess.py", line 707, in __init__
    restore_signals, start_new_session)
  File "/usr/local/lib/python3.6/subprocess.py", line 1326, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory:'wine'
alzamer2 commented 5 years ago

hi the code was made for windows but as python, it has no problem to work on other systems the problem you see is because the code tries to run mkvmerger.exe which is windows executable I don't have the much of experience in Linux, so I tried to run mkvmerger.exe with wine

RGFRv2 commented 5 years ago

I just tested under Windows (Python 3.6.0), it works without problems, downloading the video + subtitles (Free video, premium video does not work) and final MKV but under Linux (Python3.6.0), mkvmerge does not work after it is already installed.

hi the code was made for windows but as python, it has no problem to work on other systems the problem you see is because the code tries to run mkvmerger.exe which is windows executable I don't have the much of experience in Linux, so I tried to run mkvmerger.exe with wine

Any solution for download premiums videos ?

alzamer2 commented 5 years ago

by the way, the anime was downloaded but not merged you can find the unmerged files in the export folder

and for future can you tell me how to install mkvtoolnix (mkvmerger is part of it) on Linux so i can add it to code

alzamer2 commented 5 years ago

can you run the code and post for me the lines that show up befoer you start downloading?

RGFRv2 commented 5 years ago

When I installed mkvmerge I typed this command:

sudo apt-get install mkvmerge

RGFRv2 commented 5 years ago

Well, I got mkvmerge.exe running on linux.

(It worked for me, it may not work for everyone, I don't have a lot of experience on Linux)

1 - (For this command, I connected directly as root) dpkg --add-architecture i386 && apt-get update && apt-get install wine32

(After the 1st command, we can exit the root user)

2 - Second update in case sudo apt-get update

3 - Delete mkvmerge.exe in the folder "video_engine" and extract the one contained in the archive "mkvmerge.zip

4 - Try the command wine mkvmerge.exe in the folder "video_engine".

Normally if everything is OK, it should display this:

hello@server:~/tests/Crunchyroll-XML-Decoder-py3/video-engine$ wine mkvmerge.exe

Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
mkvmerge v10.0.0 ('To Drown In You') 32bit
Error: no destination file name was given.

mkvmerge -o out [global options] [options1] <file1> [@option-file.json] …

 Global options:
  -v, --verbose            Increase verbosity.
  -q, --quiet              Suppress status output.
  -o, --output out         Write to the file 'out'.
  -w, --webm               Create WebM compliant file.
  --title <title>          Title for this destination file.
  --global-tags <file>     Read global tags from an XML file.

 [...]

4 - Run the script "crunchy-xml-decoder-py3.py" and there the merge will be done without any problems

alzamer2 commented 5 years ago

can you run the code and post for me the lines that show up before you start downloading? do your name show up or Guest?

alzamer2 commented 5 years ago

Well, I got mkvmerge.exe running on linux.

(It worked for me, it may not work for everyone, I don't have a lot of experience on Linux)

1 - (For this command, I connected directly as root) dpkg --add-architecture i386 && apt-get update && apt-get install wine32

(After the 1st command, we can exit the root user)

2 - Second update in case sudo apt-get update

3 - Delete mkvmerge.exe in the folder "video_engine" and extract the one contained in the archive "mkvmerge.zip

4 - Try the command wine mkvmerge.exe in the folder "video_engine".

Normally if everything is OK, it should display this:

hello@server:~/tests/Crunchyroll-XML-Decoder-py3/video-engine$ wine mkvmerge.exe

Application tried to create a window, but no driver could be loaded.
Make sure that your X server is running and that $DISPLAY is set correctly.
mkvmerge v10.0.0 ('To Drown In You') 32bit
Error: no destination file name was given.

mkvmerge -o out [global options] [options1] <file1> [@option-file.json] …

 Global options:
  -v, --verbose            Increase verbosity.
  -q, --quiet              Suppress status output.
  -o, --output out         Write to the file 'out'.
  -w, --webm               Create WebM compliant file.
  --title <title>          Title for this destination file.
  --global-tags <file>     Read global tags from an XML file.

 [...]

4 - Run the script "crunchy-xml-decoder-py3.py" and there the merge will be done without any problems

hmm i think i cant add these steps in code, i will add them to readme instead because they need permission

RGFRv2 commented 5 years ago

You can check if OS is Windows or Linux, and start mkvmerge.exe in 'video_engine' for Windows or mkvmerge command if Linux system ?

(That not require permission to get this information normally)

alzamer2 commented 5 years ago

yes there is command in python that can check the system and version i use it to show up when the code run but i want to be sure that your cookies are loaded that why can you post try to run script and post here what show up(all of it)

RGFRv2 commented 5 years ago

There is a problem with cookies, I had to change the "sess_id" with the one I got from Crunchyroll to avoid having the error when I launch a premium episode (Video + Subs work)

Even if you reconnect with the user + pass, it doesn't work.

alzamer2 commented 5 years ago

python version=3.7.2 32 bit OS Version=Windows 10 10.0.17134 SP0 System Type=AMD64 Colorama : installed! lxml : installed! wget : installed! Cryptography : installed! Cfscrape : installed! m3u8 : installed! BeautifulSoup : installed! pager : installed! Unidecode : installed! User Name = XXXXXX Membership Type = Free Member Options: 1.- Download Anime 2.- Download Subtitle only 3.- Login 4.- Login As Guest 5.- Download an entire Anime(Autocatch links) 6.- Run Queue

999.- Settings 000.- Exit

after User Name does it show your name or Guest? in this 'XXXXXX' is the username

RGFRv2 commented 5 years ago
python version=3.6.0 64 bit
OS Version=Linux 3.16.0 4 amd64 x86_64 with debian 8.11
System Type=x86_64
Colorama : installed!
lxml : installed!
wget : installed!
Cryptography : installed!
Cfscrape : installed!
m3u8 : installed!
BeautifulSoup : installed!
pager : installed!
Unidecode : installed!
User Name = pbifh
Membership Type = Premium
Options:
1.- Download Anime
2.- Download Subtitle only
3.- Login
4.- Login As Guest
5.- Download an entire Anime(Autocatch links)
6.- Run Queue

999.- Settings
000.- Exit
>

But as I said earlier :

There is a problem with cookies, I had to change the "sess_id" with the one I got from Crunchyroll to avoid having the error when I launch a premium episode (Video + Subs work)

Even if you reconnect with the user + pass, it doesn't work.

alzamer2 commented 5 years ago

hmm delete cookies and try to log in again post the error that you get here

RGFRv2 commented 5 years ago

I deleted the cookies and restarted the script.

python version=3.6.0 64 bit                                                                                     
OS Version=Linux 3.16.0 4 amd64 x86_64 with debian 8.11
System Type=x86_64
Colorama : installed!
lxml : installed!
wget : installed!
Cryptography : installed!
Cfscrape : installed!
m3u8 : installed!
BeautifulSoup : installed!
pager : installed!
Unidecode : installed!                                                                                     
Do you have an account [Y/N]?Y                                                                                  
Username: pbifh                                                                                                 
Password(don't worry the password are typing but hidden:                                                        
Login as pbifh successfully.                                                                                    
Options:                                                                                                        
1.- Download Anime                                                                                              
2.- Download Subtitle only                                                                                      
3.- Login                                                                                                       
4.- Login As Guest                                                                                              
5.- Download an entire Anime(Autocatch links)                                                                   
6.- Run Queue                                                                                                   

999.- Settings                                                                                                  
000.- Exit                                                                                                      
> 1                                                                                                             

--------------------------                                                                                      
---- Start New Export ----                                                                                      
--------------------------                                                                                      

CrunchyRoll Downloader Toolkit DX v0.98b                                                                        

Crunchyroll hasn't changed anything.                                                                            

If you don't have a premium account, go and sign up for one now. It's well worth it, and supports the animators.

----------                                                                                                      
Booting up...                                                                                                   

Please enter Crunchyroll video URL:                                                                             
https://www.crunchyroll.com/fr/nobunaga-teachers-young-bride/episode-1-untitled-782973                          
Traceback (most recent call last):                                                                              
  File "crunchy-xml-decoder-py3.py", line 378, in <module>                                                      
    make_choise()                                                                                               
  File "crunchy-xml-decoder-py3.py", line 329, in make_choise                                                   
    ultimate()                                                                                                  
  File "crunchy-xml-decoder\ultimate.py", line 89, in ultimate                                                  
    htmlconfig = json.loads(re.findall(r'vilos\.config\.media = ({.*})',html_page_)[0])                         
IndexError: list index out of range                                                                             
alzamer2 commented 5 years ago

hmm wired i just used same link as yours and download https://www.crunchyroll.com/fr/nobunaga-teachers-young-bride/episode-1-untitled-782973

alzamer2 commented 5 years ago

i even tried it on python3 online emulator(that work on linux) and it downloaded

RGFRv2 commented 5 years ago

I don't have chance ¯_(ツ)_/¯

I got same problem with Windows and Linux even by cloning the git again.

alzamer2 commented 5 years ago

say can you go to crunchy-xml-decoder/altfuncs to line 118 and change

# print(session.get(url, params=req, headers=headers).url) to print(session.get(url, params=req, headers=headers).url)

then save what show up to txt file and upload it here

RGFRv2 commented 5 years ago

URL : https://www.crunchyroll.com/fr/nobunaga-teachers-young-bride/episode-1-untitled-782973

Please enter Crunchyroll video URL:                                                                            
https://www.crunchyroll.com/fr/nobunaga-teachers-young-bride/episode-1-untitled-782973                         
https://www.crunchyroll.com/maturity_wall?next=%2Ffr%2Fnobunaga-teachers-young-bride%2Fepisode-1-untitled-78297
3%3Fskip_wall%3D1                                                                                              
Traceback (most recent call last):                                                                             
  File "crunchy-xml-decoder-py3.py", line 379, in <module>                                                     
    make_choise()                                                                                              
  File "crunchy-xml-decoder-py3.py", line 330, in make_choise                                                  
    ultimate()                                                                                                 
  File "crunchy-xml-decoder\ultimate.py", line 90, in ultimate                                                 
    htmlconfig = json.loads(re.findall(r'vilos\.config\.media = ({.*})',html_page_)[0])                        
IndexError: list index out of range                                                                            

URL : http://www.crunchyroll.com/the-rising-of-the-shield-hero/episode-14-everlasting-memory-783051

Please enter Crunchyroll video URL:                                                                            
http://www.crunchyroll.com/the-rising-of-the-shield-hero/episode-14-everlasting-memory-783051                  
https://www.crunchyroll.com/fr/the-rising-of-the-shield-hero/episode-14-everlasting-memory-783051              
Traceback (most recent call last):                                                                             
  File "crunchy-xml-decoder-py3.py", line 379, in <module>                                                     
    make_choise()                                                                                              
  File "crunchy-xml-decoder-py3.py", line 330, in make_choise                                                  
    ultimate()                                                                                                 
  File "crunchy-xml-decoder\ultimate.py", line 129, in ultimate                                                
    hls_url = stream_url[None]                                                                                 
KeyError: None                                                                                                                                                                                                               
alzamer2 commented 5 years ago

did yoy see my last msg?

RGFRv2 commented 5 years ago

Yep i replace that :

image

And it gives me what I posted before.

alzamer2 commented 5 years ago

ohh sorry lol for got to tell you to change end to become

print(session.get(url, params=req, headers=headers).text)

RGFRv2 commented 5 years ago

I can't get more

    >
                  Português (Portugal)                </a>
              </li>
                                        <li>
                <a href="/fr/nobunaga-teachers-young-bride/episode-1-untitled-783034"
                   onclick="return Localization.SetLang(
                     'frFR',
                     'jaZYrYsOAn6cG7Yjmwc-NP5OLY7mz-FlQ05QrZwep1k',
                     '%2Ffr%2Fnobunaga-teachers-young-bride%2Fepisode-1-untitled-783034'
                   );"
                   data-language="Français (France)"
                  class="selected">
                  Français (France)                </a>
              </li>
                                        <li>
                <a href="/de/nobunaga-teachers-young-bride/episode-1-untitled-783034"
                   onclick="return Localization.SetLang(
                     'deDE',
                     'jaZYrYsOAn6cG7Yjmwc-NP5OLY7mz-FlQ05QrZwep1k',
                     '%2Fde%2Fnobunaga-teachers-young-bride%2Fepisode-1-untitled-783034'
                   );"
                   data-language="Deutsch"
                  >
                  Deutsch                </a>
              </li>
                                        <li>
                <a href="/ar/nobunaga-teachers-young-bride/episode-1-untitled-783034"
                   onclick="return Localization.SetLang(
                     'arME',
                     'jaZYrYsOAn6cG7Yjmwc-NP5OLY7mz-FlQ05QrZwep1k',
                     '%2Far%2Fnobunaga-teachers-young-bride%2Fepisode-1-untitled-783034'
                   );"
                   data-language="العربية"
                  >
                  العربية                </a>
              </li>
                                        <li>
                <a href="/it/nobunaga-teachers-young-bride/episode-1-untitled-783034"
                   onclick="return Localization.SetLang(
                     'itIT',
                     'jaZYrYsOAn6cG7Yjmwc-NP5OLY7mz-FlQ05QrZwep1k',
                     '%2Fit%2Fnobunaga-teachers-young-bride%2Fepisode-1-untitled-783034'
                   );"
                   data-language="Italiano"
                  >
                  Italiano                </a>
              </li>
                                        <li>
                <a href="/ru/nobunaga-teachers-young-bride/episode-1-untitled-783034"
                   onclick="return Localization.SetLang(
                     'ruRU',
                     'jaZYrYsOAn6cG7Yjmwc-NP5OLY7mz-FlQ05QrZwep1k',
                     '%2Fru%2Fnobunaga-teachers-young-bride%2Fepisode-1-untitled-783034'
                   );"
                   data-language="Русский"
                  >
                  Русский                </a>
              </li>
                    </ul>
      </div>

      <div class="footer-column">
        <h6>Support</h6>
        <ul>
          <li><a href="https://crunchyroll.zendesk.com/hc" token="bottombar">Aide/FAQ</a></li>
        </ul>
              </div>

      <div class="footer-column">
        <h6>Crunchyroll</h6>
        <ul>
          <li><a href="/fr/about" token="bottombar">À propos</a></li>
          <li><a href="/jobs" token="bottombar">Offres d'emploi</a></li>
          <li><a href="/advertising" token="bottombar">Publicité</a></li>
                    <li><a href="/dmca_policy" token="bottombar">Copyright</a></li>
          <li><a href="/tos" token="bottombar">Conditions générales</a></li>
          <li><a href="/privacy" token="bottombar">Politique de confidentialité <span class="new-footer">Beta</span></a></li>
        </ul>
      </div>
    </div>

    <div id="social_media">
      <div class="footer-column">
        <a href="/feed" token="bottombar">
          <img class="icon" src="https://www.crunchyroll.com/i/rss.png" alt="rss" />
        </a>
        <a href="/feed" token="bottombar">Flux RSS</a>
      </div>
      <div class="footer-column">
        <a href="https://twitter.com/Crunchyroll_fr" class="twitter-follow-button" data-show-count="false">Follow
  @Crunchyroll_fr</a>
<script>!function (d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (!d.getElementById(id)) {
      js = d.createElement(s);
      js.id = id;
      js.src = "https://platform.twitter.com/widgets.js";
      fjs.parentNode.insertBefore(js, fjs);
    }
  }(document, "script", "twitter-wjs");</script>
      </div>
      <div class="footer-column">
        <div class="fb-like" data-href="https://www.facebook.com/crunchyroll.fr" data-layout="button_count" data-action="like" data-show-faces="true" data-share="false"></div>
      </div>
    </div>
  </div>
  </div>
              </div>
    </div>

<script type="text/javascript">
$(document).ready(function(e) {
  // temp_ad
  var cookie = readCookie('temp_ad_closed');

  // show ad if no cookie is set
  if(cookie == 1){
    $('#temp_ad').hide();
    killAd();
  }else{
    $('#temp_ad').show();
  }

  function tempAd(){
    var contentOffset = $('#template_body').offset();
    var contentWidth = $('#template_body').width();
    var windowWidth = $(window).width();
    var tempAdv = $('#temp_ad');
    tempAdv.offset({left: contentOffset.left + contentWidth - 180});
  }
  tempAd();
  $(window).resize(function(){
    tempAd();
  });
  $('#temp_ad').hover(function(){
    $(this).stop().animate({
      opacity: 1,
      bottom: 0
    },500,function(){
      $(this).find('.close').fadeIn(200);
    });
  },function(){
    $(this).find('.close').fadeOut(200);
    $(this).stop().animate({
      opacity: 0.85,
      bottom: -140
    },500,function(){});
  });

  function killAd(){
    $('#temp_ad').fadeOut(400, function(){
      $('#temp_ad').remove();
    });
  }

  $('#temp_ad .close').click(function(){
    killAd();
    createCookie('temp_ad_closed',1,7);
  });
  // end of temp_ad code

  $('a').each(function() {
    trackToken(this);
  });
  CharacterCounter.Init();

  if($('.main-page').css('background-image') == 'none'){
    $('.template-container').addClass('no-adskin');
  }
});

$(window).bind('beforeunload',function () {
  if (Page.warnOnLeavingPageMessage) {
    return Page.warnOnLeavingPageMessage;
  }
});

gapi.plusone.go();
</script>
    <script>
  var is_premium = false;
  var ga = ga || function noop() {
    // Do nothing
  };

  $('#header_search_input').on('click', function trackSearch() {
    ga('send', 'event', 'homepage', 'search', 'click');
  });

  $('#header_account_settings').on('click', function trackAccountSettings() {
    if (is_premium) {
      ga('send', 'event', 'Cancel', 'Cancel.Settings.click');
    }
  });
</script>
<script type="text/javascript">
  var _qevents = _qevents || [];

  (function() {
    var elem = document.createElement('script');
    elem.src = (document.location.protocol == "https:" ? "https://secure" : "http://edge") + ".quantserve.com/quant.js";
    elem.async = true;
    elem.type = "text/javascript";
    var scpt = document.getElementsByTagName('script')[0];
    scpt.parentNode.insertBefore(elem, scpt);
  })();

  _qevents.push({
    qacct:"p-2c9Xi7EeE3Hx2"
  });
</script>
<noscript>
  <div style="display:none;">
    <img src="//pixel.quantserve.com/pixel/p-2c9Xi7EeE3Hx2.gif" border="0" height="1" width="1" alt="Quantcast"/>
  </div>
</noscript>
<script type="text/javascript">
  var _comscore = _comscore || [];
  _comscore.push({ c1: "2", c2: "15801199" });
  (function() {
    var s = document.createElement("script"), el = document.getElementsByTagName("script")[0]; s.async = true;
    s.src = (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js";
    el.parentNode.insertBefore(s, el);
  })();
</script>
<noscript>
  <img src="//sb.scorecardresearch.com/p?c1=2&amp;c2=7021617&amp;cv=2.0&amp;cj=1" />
</noscript>

<div style="display: none;">
  <script>
    /* <![CDATA[ */
    var google_conversion_id = 982007020;
    var google_conversion_format = "3";
    var google_remarketing_only = true;
      var google_conversion_value = 0;
          /* ]]> */
  </script>
  <script src="//www.googleadservices.com/pagead/conversion.js"></script>
  <noscript>
    <div style="display: inline;">
      <img height="1" width="1" style="border-style: none;" alt=""
           src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/982007020/?guid=ON&amp;script=0&amp;value=0"/>
    </div>
  </noscript>
</div>
<script>
  adroll_adv_id = "S3XDMOUT55F43EDQZFISDA";
  adroll_pix_id = "3GKIBNN7JBASTNGN7GWJBD";
  (function () {
    var oldonload = window.onload;
    window.onload = function () {
      __adroll_loaded = true;
      var scr = document.createElement("script");
      var host = (("https:" == document.location.protocol) ? "https://s.adroll.com" : "http://a.adroll.com");
      scr.setAttribute('async', 'true');
      scr.type = "text/javascript";
      scr.src = host + "/j/roundtrip.js";
      ((document.getElementsByTagName('head') || [null])[0] ||
      document.getElementsByTagName('script')[0].parentNode).appendChild(scr);
      if (oldonload) {
        oldonload()
      }
    };
  }());
</script>

<script src="https://platform.twitter.com/oct.js"></script>
<script>
    if (twttr.conversion) {
    twttr.conversion.trackPid('l4wzz');
  }
</script>
<noscript>
  <img height="1" width="1" style="display: none;" alt=""
       src="https://analytics.twitter.com/i/adsct?txn_id=l4wzz&p_id=Twitter"/>
  <img height="1" width="1" style="display: none;" alt="" src="//t.co/i/adsct?txn_id=l4wzz&p_id=Twitter"/>
</noscript>

<script>
  'use strict';

  document.addEventListener('DOMContentLoaded', function setUpTruoptikTracking() {
    if (!Components.TruoptikTrackingFacade) {
      return;
    }

    var truoptikFacade = new Components.TruoptikTrackingFacade();

    truoptikFacade.initialize().then(function() {
      truoptikFacade.sendCustomData({"email":null,"name":null,"date_of_birth":null,"gender":null,"premium_status":"free","country_code":"FR"});
    });
  });
</script><script>
  !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="4.0.0";}}();

  (function initializeSegment() {
    const segmentKey = 'KC3ITMkcWCrn2dZrMXlkjNQBaFSB9ilG';
    const fallbackApiHost = 'cr-eec.etp-prod.com/v1';
    const fallbackLibraryHost = 'https://sa.etp-prod.com/analytics.js/v1/' + segmentKey + '/analytics.min.js';

    const defaultApiHost = 'cr-eec.etp-prod.com/v1';
    const defaultLibraryHost = 'https://cdn.segment.io/analytics.js/v1/' + segmentKey + '/analytics.min.js';

    function loadSegmentScript(segmentKey, successCallback, errorCallback) {
      const script = document.createElement('script');
      script.type = 'text/javascript';
      script.async = !0;
      script.src = defaultLibraryHost;

      script.onload = function () {
        successCallback();
      };

      script.onerror = function () {
        errorCallback();
      };

      var firstScript = document.getElementsByTagName('script')[0];
      firstScript.parentNode.insertBefore(script, firstScript)
    }

    function overrideSegmentHost() {
      window.analytics._integrations['Segment.io'].options.apiHost = defaultApiHost;

      const req = new XMLHttpRequest();
      req.open('POST', 'https://' + defaultApiHost + '/batch');
      req.setRequestHeader('Content-Type', 'application/json');
      req.addEventListener('error', function () {
        if (req.status === 0) { // BLOCK BY CLIENT STATUS CODE
          window.analytics._integrations['Segment.io'].options.apiHost = fallbackApiHost;
        }
      });
      // POST an empty batch action to check if api.segment.io is available
      req.send(JSON.stringify({batch: []}));
    }

    function loadSegmentFallbackLibrary() {
      const script = document.createElement('script');
      script.type = 'text/javascript';
      script.async = !0;
      script.src = fallbackLibraryHost;

      script.onload = function () {
        window.analytics._integrations['Segment.io'].options.apiHost = fallbackApiHost;
      };

      const firstScript = document.getElementsByTagName('script')[0];
      firstScript.parentNode.insertBefore(script, firstScript);
    }

    function identify(anonymousId) {
      let analytics = window.analytics,
        traits = {anonymousId: anonymousId};

            analytics.identify("", traits);

      let page_metadata = $.extend({
        channelName: '',
        modal: '',
        referrer: document.referrer,
        pageLoadTime: ''
      }, {"experiment":"","isAuthenticated":false,"ContentMedia":{"channelName":"","mediaType":"episode","mediaId":"G63K98DZ6","mediaTitle":"Nobunaga teacher's young bride","seasonTitle":"Nobunaga teacher's young bride","episodeTitle":"Untitled","episodeNumber":"1","extraTitle":""}});

      analytics.page(page_metadata);
    }

    loadSegmentScript(segmentKey, overrideSegmentHost, loadSegmentFallbackLibrary);

    triggerSegmentIdentifyExecuted();

    let isAnalyticsReady = false;
    window.analytics.ready(function () {
      isAnalyticsReady = true;
      identify(window.analytics.user().anonymousId());
    });

    // Trigger segment identify in case analytics didn't triggered "ready" event
    setTimeout(function () {
      if (!isAnalyticsReady) {
        identify(null);
      }
    }, 5000);
  })();

  (function registerSegmentEvents() {
    window.segment = {
      track: function () {
        this.trackLoginSelected();
        this.trackLoginFailed();
        this.trackLoginRequested();

        this.trackRegistrationSelected();
        this.trackRegistrationFailed();
        this.trackRegistrationRequested();
        this.trackLinkAccountPermissionsAgreed();
        this.trackLinkAccountPermissionsDisagree();
        this.trackLinkAccountRequested();

        this.trackPaymentMethodSelected();
        this.trackUpsellSelected();
        this.trackHappyMealUpsellSelected();
        this.trackAnchorNavigated();
        this.trackHelpFaq();
        this.trackSubscriptionRequested();

        this.trackFreeTrialSelectedContinue();
        this.trackTosSelected();
        this.trackPrivacySelected();
        this.trackPasswordResetNavigated();
        this.trackHomeSelected();
        this.trackWhatIsVRV();
        this.trackHmVrvRegistrationRequested();
        this.trackManualSigninNavigated();

        this.trackShoppingContinued();
        this.trackCartUpdated();
        this.trackCheckoutStarted();
      },

      trackLoginRequested: function () {
        $('#login_submit_button').click(function () {
          analytics.track('Login Requested', {
            loginId: $('#login_form_name').val(),
            ActionDetail: helper.buildActionDetail($(this), 'right')
          })
        });

        $('#freetrial_landing_login_form').find('button').click(function () {
          analytics.track('Login Requested', {
            loginId: $('#login_form_name').val(),
            ActionDetail: helper.buildActionDetailForHappyMeal($(this), 'right')
          })
        });
      },

      trackLoginSelected: function () {
        $('#header_userpanel_beta').find('.login a').click(function () {
          analytics.track('Login Selected', {
            ActionDetail: helper.buildActionDetail($(this).find('.caption'), 'header')
          })
        });

        $('.showmedia-free-trial-already-have-account a').click(function () {
          analytics.track('Login Selected', {
            ActionDetail: helper.buildActionDetail($(this), 'right')
          })
        });

        $('#freetrial_landing_select_login_form').click(function () {
          analytics.track('Login Selected', {
            ActionDetail: helper.buildActionDetailForHappyMeal($(this), 'right')
          })
        })
      },

      trackLoginFailed: function () {
        var errors = $('#login_form').find('li.error');
        if (errors.length > 0) {
          analytics.track('Login Failed', {
            emailAddress: $('#login_form_name').val(),
            failureReason: errors.first().text()
          });
        }

        errors = $('#freetrial_login_form').find('li.error');
        if (errors.length > 0) {
          analytics.track('Login Failed', {
            emailAddress: $('#login_form_name').val(),
            failureReason: errors.first().text()
          });
        }
      },

      trackRegistrationRequested: function () {
        $('#signup_form #signup_submit_button').click(function () {
          analytics.track('Registration Requested', {
            emailAddress: $('#signup_with_profile_email').val(),
            ActionDetail: helper.buildActionDetail($(this), 'left')
          })
        });

        $('#showmedia_free_trial_signup').find('a.button').click(function () {
          analytics.track('Registration Requested', {
            emailAddress: $('#new_email').val(),
            ActionDetail: helper.buildActionDetail($(this), 'right')
          })
        });

        $('#freetrial_signup_form #signup_submit_button').click(function () {
          analytics.track('Registration Requested', {
            emailAddress: $('#signup_email').val(),
            ActionDetail: helper.buildActionDetailForHappyMeal($(this), 'right')
          });

          //catch ajax validation errors
          segment.trackRegistrationFailed();
        });
      },

      trackRegistrationFailed: function () {
        var errors = $('#signup_form').find('li.error');
        if (errors.length > 0) {
          analytics.track('Registration Failed', {
            emailAddress: $('#signup_with_profile_email').val(),
            failureReason: errors.first().text()
          });
        }

        errors = $('#freetrial_signup_form').find('li.error');
        if (errors.length > 0) {
          analytics.track('Registration Failed', {
            emailAddress: $('#freetrial_signup_form #signup_email').val(),
            failureReason: errors.first().text()
          });
        }
      },

      trackRegistrationSelected: function () {
        $('#freetrial_landing_select_signup_form').click(function () {
          analytics.track('Registration Selected', {
            ActionDetail: helper.buildActionDetailForHappyMeal($(this), 'right')
          })
        })
      },

      trackLinkAccountPermissionsAgreed: function () {
        $('.permissions-request #allow_link').click(function () {
          analytics.track('Link Accounts Permissions Agreed', {
            ActionDetail: helper.buildActionDetail($(this), 'bottom')
          })
        });
      },

      trackLinkAccountPermissionsDisagree: function () {
        $('.permissions-request #deny_link').click(function () {
          analytics.track('Link Accounts Permissions Disagree', {
            ActionDetail: helper.buildActionDetail($(this), 'bottom')
          })
        });
      },

      trackLinkAccountRequested: function () {
        $('form[name="partners_login_form"]').submit(function () {
          analytics.track('Link Accounts Requested', {
            ActionDetail: helper.buildActionDetail($(this).find('#log_in_submit_button'), 'bottom')
          })
        });
      },

      trackPaymentMethodSelected: function () {
        $('.subscription-page #payment_method_credit_card').click(clickOnPaymentMethod('CreditCard'));
        $('.subscription-page #payment_method_paypal').click(clickOnPaymentMethod('PayPal'));

        function clickOnPaymentMethod(method) {
          return function () {
            analytics.track('Payment Method Selected', {
              method: method
            });
          }
        }
      },

      trackSubscriptionSelected: function (element, sku) {
        var infoObject = {
          ActionDetail: helper.buildActionDetail(element, 'center')
        };

        if (sku) {
          infoObject.SKU = {
            skuId: sku.id,
            skuTitle: sku.title,
            skuType: sku.type
          };
        }

        analytics.track('Subscription Selected', infoObject);
      },

      trackFreeTrialSelected: function (element, sku) {
        if (!sku) {
          return;
        }

        var infoObject = {
          SKU: {
            skuId: sku.id,
            skuTitle: sku.title,
            skuType: sku.type
          },
          ActionDetail: helper.buildActionDetail(element, 'center')
        };

        analytics.track('Free Trial Selected', infoObject);
      },

      trackCustomEvent: function (event, data) {
        analytics.track(event, data);
      },

      trackSubscriptionCanceled: function (sku) {
        analytics.track('Subscription Canceled', {
          SKU: {
            skuId: sku,
            skuTitle: '',
            skuType: ''
          }
        });
      },

      trackSubscriptionRequested: function () {
        $('#premium_pick_plan_container').find('.premium-pick-plan-choices a').click(function () {
          analytics.track('Subscription Requested', {
            ActionDetail: helper.buildActionDetail($(this), 'center', $(this).attr('data-text')),
            SKU: {
              skuId: $(this).attr('data-sku'),
              skuTitle: '',
              skuType: ''
            }
          });
        });
      },

      trackUpsellSelected: function () {
        $('#header_try_premium_free').click(trackEvent('top', 'Premium try free'));
        $('#footer_compare_plans, #footer_two_week_free_trial').click(trackEvent('bottom'));
        $('#cancellation_try_vrv_button').click(trackEvent('center'));
        $('#get_funimation_button, #vrv_offline_view_ad, #vrv_funimation_and_offline_view_ad')
          .click(trackEvent('right', 'Find Out More'));

        function trackEvent(position, text) {
          return function () {
            analytics.track('Upsell Selected', {
              ActionDetail: helper.buildActionDetail($(this), position, text)
            });
          }
        }
      },

      trackHappyMealUpsellSelected: function () {
        $('.happy-meal-upsell-button').click(function () {
          var element = $(this);

          analytics.track('Upsell Selected', {
            ActionDetail: helper.buildActionDetail($(this), element.data('position')),
            SKU: {
              skuId: element.data('id'),
              skuTitle: element.data('title'),
              skuType: 'alLaCarte',
            }
          });
        });
      },

      trackAnchorNavigated: function () {
        $('.top-menu-anchor-navigated').click(function () {
          analytics.track('Anchor Navigated', {
            ActionDetail: helper.buildActionDetail($(this), 'top'),
          });
        });
      },

      trackHelpFaq: function () {
        $('.bottom-help-faq').click(function () {
          analytics.track('Help/FAQ', {
            ActionDetail: helper.buildActionDetail($(this), 'bottom'),
          });
        });
      },

      trackSubscriptionCancelRequested: function () {
        analytics.track('Subscription Cancel Requested');
      },

      trackSubscriptionCancelConfirmed: function () {
        analytics.track('Subscription Cancel Confirmed');
      },

      trackSubscriptionCancelSelected: function () {
        analytics.track('Subscription Cancel Selected');
      },

      trackFreeTrialCancelled: function (sku) {
        analytics.track('Free Trial Cancelled', {
          SKU: {
            skuId: sku,
            skuTitle: '',
            skuType: ''
          }
        });
      },

      trackFreeTrialSelectedContinue: function () {
        $('#js_continue_free_trial').click(function () {
          var element = $(this);
          analytics.track('Free Trial Selected', {
            ActionDetail: helper.buildActionDetail(element, 'right'),
            SKU: {
              skuId: element.data('sku'),
              skuTitle: '',
              skuType: ''
            },
            ExternalReferrer: {
              referrerId: '',
              referrerLink: '',
              referrerName: '',
              referrerType: '',
              referrerUrl: ''
            },
            lengthOfFreeTrial: '14 Days'
          });
        });
      },

      trackUpsellDisplayed: function (textOfButtonOrLink, position) {
        analytics.track('Upsell Displayed', {
          textOfButtonOrLink: textOfButtonOrLink,
          position: position
        });
      },

      trackExperimentViewed: function (experiment, variant) {
        analytics.track('Experiment Viewed', {
          experimentId: experiment,
          variantId: variant
        });
      },

      trackExperimentListViewed: function (experimentList) {
        let that = this;
        $.each(experimentList, function (experiment, variant) {
          that.trackExperimentViewed(experiment, variant);
        });
      },

      trackHomeSelected: function () {
        $('#isolated_page_home_link, #home_link').click(function () {
          analytics.track('Home Selected', {
            ActionDetail: helper.buildActionDetailForHappyMeal($(this), 'left')
          });
        });
      },

      trackWhatIsVRV: function () {
        $('#what_is_vrv').click(function () {
          analytics.track('What is VRV Navigated', {
            ActionDetail: helper.buildActionDetail($(this), 'left')
          })
        });
      },

      trackTosSelected: function () {
        $('#freetrial_landing_signup_form').find('#tos_link').click(function () {
          analytics.track('Terms Selected', {
            ActionDetail: helper.buildActionDetail($(this), 'right')
          })
        });
      },

      trackPrivacySelected: function () {
        $('#freetrial_landing_signup_form').find('#privacy_link').click(function () {
          analytics.track('Privacy Selected', {
            ActionDetail: helper.buildActionDetail($(this), 'right')
          });
        })
      },

      trackPasswordResetNavigated: function () {
        $('#freetrial_login_form').find('.forgot-password-link').click(function () {
          analytics.track('Password Reset Navigated', {
            ActionDetail: helper.buildActionDetail($(this), 'right')
          });
        })
      },

      trackHappyMealExitToCR: function () {
        analytics.track('HM Exited to Crunchyroll');
      },

      trackHappyMealExitToVRV: function () {
        analytics.track('HM Exited to VRV');
      },

      trackSFPHomeSelected: function() {
        analytics.track('Home Selected', {
          ActionDetail: helper.buildActionDetail($(this), 'top left', $(this).attr('href')),
          referrer: document.referrer
        });
      },

      trackSFPHelp: function() {
        analytics.track('SFP Help/FAQ', {
          ActionDetail: helper.buildActionDetail($(this), 'bottom'),
          referrer: document.referrer
        })
      },

      trackHmVrvRegistrationRequested: function () {
        $('#activate_vrv_account').submit(function () {
          analytics.track('HM VRV Registration Requested', {
            ActionDetail: helper.buildActionDetail($(this), 'center')
          });
        });
      },

      trackManualSigninNavigated: function () {
        $('#create_or_sign_in_vrv_account').click(function () {
          analytics.track('Manual Signin Navigated', {
            ActionDetail: helper.buildActionDetail($(this), 'bottom')
          });
        });
      },

      trackErrorBannerDisplayed: function (element) {
        analytics.track('Error Banner Displayed', {
          ActionDetail: helper.buildActionDetail($(element), 'center')
        });
      },

      trackErrorBannerNavigated: function () {
        analytics.track('Error Banner Navigated', {
          ActionDetail: helper.buildActionDetail($(this), 'center')
        });
      },

      trackShoppingContinued: function () {
        $('#continue_shopping').click(function () {
          analytics.track('Shopping Continued');
        });
      },

      trackCartUpdated: function () {
        $('#update_cart').click(function () {
            analytics.track('Cart Updated');
          }
        );
      },

      trackCartViewed: function (cart) {
        analytics.track('Cart Viewed', cart);
      },

      trackGetShippingEstimate: function (countryCode, zip) {
        analytics.track('Get Shipping Estimate', {
          country: countryCode,
          zip: zip
        });
      },

      trackCheckoutStarted: function () {
        $('#checkout_cart').click(function () {
          analytics.track('Checkout Started');
        });
      },

      trackOrderCompleted: function (orderId) {
        analytics.track('Order Completed', {
          orderId: orderId
        });
      },

      trackPartnerLoginViewed: function (partnerId, partnerName) {
        analytics.track('Partner Login', {
          partnerId: partnerId,
          partnerName: partnerName
        });
      },

      trackPartnerLoginRequested: function (loginId, partnerId, partnerName) {
        analytics.track('Partner Login Requested', {
          partnerId: partnerId,
          partnerName: partnerName,
          loginId: loginId
        });
      }
    };

    $(function () {
      segment.track();
    });

    var helper = {
      buildActionDetail: function (element, position, text) {
        return {
          textOfButtonOrLink: text || element.text().trim(),
          pageOrScreen: $(document).find('head title').text(),
          position: position || ''
        }
      },
      buildActionDetailForHappyMeal: function (element, position, text) {
        var actionDetail = this.buildActionDetail(element, position, text);
        var happyMealVariant = null;

        if (happyMealVariant) {
          return $.extend(actionDetail, {experiment: 'HappyMeal.E31.' + happyMealVariant});
        }

        return actionDetail;
      }
    };
  })();

  //hack to make vilos work when an adblocker is present
  //we use segment anonymous_id in vilos configuration, which is generated in analytics.identify
  //this listener has to be added after loading segment and before calling analytics.identify, can't do it when loading vilos
  function triggerSegmentIdentifyExecuted() {
    let isVilosLoaded = false;

    window.analytics.on('invoke', function (o) {
      if (!o.obj || !o.obj.anonymousId || isVilosLoaded) {
        return;
      }

      if (typeof window.CustomEvent === 'function') {
        document.dispatchEvent(new CustomEvent('SEGMENT_IDENTIFY_EXECUTED', {
          detail: {
            segment_anonymous_id: o.obj.anonymousId
          }
        }));
      } else {
        //IE compatibility
        let event = document
          .createEvent('CustomEvent')
          .initCustomEvent('SEGMENT_IDENTIFY_EXECUTED', false, false, {
            segment_anonymous_id: o.obj.anonymousId
          });

        document.dispatchEvent(event);
      }

      isVilosLoaded = true;
    });
  }
</script>
  <script type="text/javascript">window.NREUM||(NREUM={});NREUM.info={"beacon":"bam.nr-data.net","licenseKey":"bad6e2948e","applicationID":"109843800","transactionName":"NFZQZ0IAD0BRVkddXw0ccUZDFQ5eH1ZBDkMLXEVeVQUIUg==","queueTime":0,"applicationTime":138,"atts":"GBFTEQoaHE4=","errorBeacon":"bam.nr-data.net","agent":""}</script></body>
</html>
<script type="text/javascript">
  (function() {
    var criteo_q = window.criteo_q || [];
    var deviceType = /iPad/.test(navigator.userAgent) ? "t" :
      /Mobile|iP(hone|od)|Android|BlackBerry|IEMobile|Silk/.test(navigator.userAgent) ? "m"
        : "d";

    var criteoJs = document.createElement("script");
    criteoJs.type = 'text/javascript';
    criteoJs.src = '//static.criteo.net/js/ld/ld.js';
    criteoJs.async = 'true';
    document.head.appendChild(criteoJs);

    criteo_q.push(
      {event: "setAccount", account: 47983},
      {event: "setSiteType", type: deviceType},
      {event: "setHashedEmail", email: ""},
      {event: "setData", ui_account: ""}
    );

    var eventDetails = [{"event":"viewItem","item":"277790"}];
    if (eventDetails) {
      criteo_q.push(eventDetails);
    }
    window.criteo_q = criteo_q;
  })();

  function pushDynamicProductsIdsCriteoEvent(products) {
    var items = [];
    if (products) {
      // https://support.criteo.com/hc/en-us/articles/203392521-Criteo-OneTag-on-your-search-listing-page
      // you will have to pass dynamically the product IDs for the top three products displayed on the page
      for (var i = 0; i < 3; i++) {
        if (products[i] && products[i].product_id && products[i].status !== "private") {
          items.push(products[i].product_id);
        }
      }
    }

    window.criteo_q.push({event: "viewList", item: items});
  }

  function pushDynamicCartItemsCriteoEvent(cartItems) {
    var items = [];
    if (cartItems) {
      for (var i = 0; i < cartItems.length; i++) {
        if (cartItems[i] && cartItems[i].product) {
          items[i] = {
            quantity: cartItems[i].quantity,
            price: cartItems[i].price,
            id: cartItems[i].product_id
          }
        }
      }
    }

    window.criteo_q.push({event: "viewBasket", item: items});
  }
</script>

Traceback (most recent call last):
  File ".\crunchy-xml-decoder-py3.py", line 379, in <module>
    make_choise()
  File ".\crunchy-xml-decoder-py3.py", line 330, in make_choise
    ultimate()
  File "crunchy-xml-decoder\ultimate.py", line 129, in ultimate
    hls_url = stream_url[None]
KeyError: None
alzamer2 commented 5 years ago

ok let try this instead res = session.get(url, params=req, headers=headers) print(session.get(url, params=req, headers=headers).text) res.encoding = 'UTF-8' return res.text to res = session.get(url, params=req, headers=headers) # print(session.get(url, params=req, headers=headers).url) res.encoding = 'UTF-8' open('page.html', 'a',encoding='UTF-8').write(res.text) return res.text

there should be page.html file in dirctury zip it and uplode it here

RGFRv2 commented 5 years ago

Done page.zip

alzamer2 commented 5 years ago

go to cookies and copy sess_id value then add it after this url and tell me what you get http://api.crunchyroll.com/start_session.0.json?session_id=

alzamer2 commented 5 years ago

from what i saw from page html there is problem in injecting sess_id

RGFRv2 commented 5 years ago

If i replace the content of sess_id with sess_id_usa, that work

alzamer2 commented 5 years ago

ohh i think i know where the problem for now try to go to settings and enable 5.- USA Proxy just input 5 then try downloadingand repost page.html here

RGFRv2 commented 5 years ago

It's working with USA Proxy : True page.zip

alzamer2 commented 5 years ago

as i excpected ok i updated the code can you try it out for me?

RGFRv2 commented 5 years ago

as i excpected ok i updated the code can you try it out for me?

It works perfectly.

alzamer2 commented 5 years ago

nice say when you tried sess_id_usa with http://api.crunchyroll.com/start_session.0.json?session_id= what did it say for premium? was there any value for plus?

alzamer2 commented 5 years ago

trying to update code so it say if you are premium or premium plus

RGFRv2 commented 5 years ago

nice say when you tried sess_id_usa with http://api.crunchyroll.com/start_session.0.json?session_id= what did it say for premium? was there any value for plus?

trying to update code so it say if you are premium or premium plus

I've got premium_plus "access_type":"premium_plus"

alzamer2 commented 5 years ago

ok i updated the code try it out and tell me if you get 'premium' or 'premium plus'

RGFRv2 commented 5 years ago

ok i updated the code try it out and tell me if you get 'premium' or 'premium plus'

Show Premium Plus because my account is Premium Plus ^^

alzamer2 commented 5 years ago

nice ok i will close this issue if you need any thing open new one ^^