Audio/video stream recording forums

Attention Visitor:
You may have to register or log in before you can post:
  • Click the register link to sign up.
  • Registered members please fill in the form below and click the "Log in" button.
To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Audio/video stream recording forums > Streaming media recording forum > Video stream recording
Register FAQ Members List Calendar Mark Forums Read

Reply Post New Thread
 
Thread Tools Display Modes
  #11  
Old 06-10-2015, 10:13 AM
AlvoErrado2 AlvoErrado2 is offline
Member
 
Join Date: Aug 2014
Location: Brazil
Posts: 52
AlvoErrado2 is on a distinguished road
Default

Re: Download closed captions from Hulu


Quote:
Originally Posted by stinkfoot View Post
yes being encrypting smi. yes decrypting php using kodi php scripting reposit or other php.

also choosing webvtt or ttml. hulu no encryption webvtt ttml. may downloading no having being encrypting. no needing php scripting.
Code:
import xbmc
import xbmcgui
import xbmcplugin
import common
import os
import binascii
import re
import math

import datetime


from BeautifulSoup import BeautifulSoup

try:
    from xml.etree import ElementTree
except:
    from elementtree import ElementTree

subdeckeys  = [ common.xmldeckeys[0] ]

class Main:
    def __init__( self ):
        pass

    def PlayWaitSubtitles(self, video_id):
        while not xbmc.Player().isPlaying():
            print 'HULU --> Not Playing'
            xbmc.sleep(100)
        self.SetSubtitles(video_id)
    
    def SetSubtitles(self, video_id):
        subtitles = os.path.join(common.pluginpath,'resources','cache',video_id+'.srt')
        self.checkCaptions(video_id)
        if os.path.isfile(subtitles) and xbmc.Player().isPlaying():
            print "HULU --> Subtitles Enabled."
            xbmc.Player().setSubtitles(subtitles)
        elif xbmc.Player().isPlaying():
            print "HULU --> Subtitles Disabled."
        else:
            print "HULU --> No Media Playing. Subtitles Not Assigned."
        
    def checkCaptions(self, video_id):
        subtitles = os.path.join(common.pluginpath,'resources','cache',video_id+'.srt')
        if os.path.isfile(subtitles):
            print "HULU --> Using Cached Subtitles"
        else:
            url = 'http://www.hulu.com/captions?content_id='+video_id
            xml = common.getFEED(url)
            tree = ElementTree.XML(xml)
            hasSubs = tree.findtext('en')
            if(hasSubs):
                print "HULU --> Grabbing subtitles..."
                subtitles = self.convert_subtitles(hasSubs)
                common.SaveFile(os.path.join(common.pluginpath,'resources','cache',video_id+'.srt'), subtitles)
                print "HULU: --> Successfully converted subtitles to SRT"
            else:
                print "HULU --> No subtitles available."
                
    def convert_subtitles(self, url):
        xml=common.getFEED(url)
        tree = ElementTree.XML(xml)
        lines = tree.find('BODY').findall('SYNC')
        srt_output = ''
        count = 1
        displaycount = 1
        for line in lines:
            if(line.get('Encrypted') == 'true'):
                sub = self.decrypt_subs(line.text)
            else:
                sub = line.text
            sub = self.clean_subs(sub)
            if sub == '':
                count += 1
                continue
            start = self.convert_time(int(line.get('start')))
            if count < len(lines):
                end = self.convert_time(int(lines[count].get('start')))
            line = str(displaycount)+"\n"+start+" --> "+end+"\n"+sub+"\n\n"
            srt_output += line
            count += 1
            displaycount += 1
        return srt_output

    def decrypt_subs(self, encsubs):
        encdata = binascii.unhexlify(encsubs)
        for key in subdeckeys[:]:
            cbc = common.AES_CBC(binascii.unhexlify(key[0]))
            subs = cbc.decrypt(encdata,key[1])
            substart = subs.find("<P")
            if (substart > -1):
                i = subs.rfind("</P>")
                subs = subs[substart:i+4]
                return subs

    def clean_subs(self, data):
        br = re.compile(r'<br.*?>')
        tag = re.compile(r'<.*?>')
        space = re.compile(r'\s\s\s+')
        sub = br.sub('\n', data)
        sub = tag.sub(' ', sub)
        sub = space.sub(' ', sub)
        sub = sub.replace(' ',' ').strip()
        if sub <> '':
            sub = BeautifulSoup(sub,convertEntities=BeautifulSoup.HTML_ENTITIES).contents[0].string.encode( "utf-8" )
            sub = BeautifulSoup(sub,convertEntities=BeautifulSoup.XML_ENTITIES).contents[0].string.encode( "utf-8" )
        return sub

    def convert_time(self, milliseconds):
        seconds = int(float(milliseconds)/1000)
        milliseconds -= (seconds*1000)
        hours = seconds / 3600
        seconds -= 3600*hours
        minutes = seconds / 60
        seconds -= 60*minutes
        return "%02d:%02d:%02d,%3d" % (hours, minutes, seconds, milliseconds)
Looking at this python script, I think this is the way.

But now I will have to study to learn how to adapt this script for what I want. Eliminating the parts for the xbmc / kodi must come to some conclusion.
Reply With Quote
  #12  
Old 06-10-2015, 03:27 PM
stinkfoot stinkfoot is offline
Fodder Ildelugtende
 
Join Date: Feb 2015
Posts: 132
stinkfoot is on a distinguished road
Default

Re: Download closed captions from Hulu


choosing and downloading webvtt or ttml from hulu then no needing decrypting. you must having smi instead of webvtt or ttml?
Reply With Quote
  #13  
Old 06-12-2015, 09:48 AM
AlvoErrado2 AlvoErrado2 is offline
Member
 
Join Date: Aug 2014
Location: Brazil
Posts: 52
AlvoErrado2 is on a distinguished road
Default

Re: Download closed captions from Hulu


Quote:
Originally Posted by stinkfoot View Post
choosing and downloading webvtt or ttml from hulu then no needing decrypting. you must having smi instead of webvtt or ttml?
I don't know how to change this option for this show, i'm not interested in the video, only in subs, is for my english classes.

Code:
http://www.hulu.com/watch/676589
Reply With Quote
  #14  
Old 06-12-2015, 04:43 PM
stinkfoot stinkfoot is offline
Fodder Ildelugtende
 
Join Date: Feb 2015
Posts: 132
stinkfoot is on a distinguished road
Default

Re: Download closed captions from Hulu


Quote:
Originally Posted by AlvoErrado2 View Post
I don't know how to change this option for this show, i'm not interested in the video, only in subs, is for my english classes.

Code:
http://www.hulu.com/watch/676589
yes I trying learning english too!
best method being typing it.
no cheating using google translate. google translate making you lazy.
Code:
http://assets.huluim.com/captions_webvtt/333/60425333_US_en_en.vtt
Reply With Quote
  #15  
Old 06-12-2015, 07:05 PM
AlvoErrado2 AlvoErrado2 is offline
Member
 
Join Date: Aug 2014
Location: Brazil
Posts: 52
AlvoErrado2 is on a distinguished road
Default

Re: Download closed captions from Hulu


Thank you very much!
Reply With Quote
  #16  
Old 10-19-2015, 02:41 PM
Rancher Rancher is offline
Junior Member
 
Join Date: Nov 2012
Posts: 29
Rancher is on a distinguished road
Default

Re: Download closed captions from Hulu


Is there a way to encrypt the subtitles (.smi, .ass, .srt…)? A script or something? Thank you in advance.
Reply With Quote
  #17  
Old 10-19-2015, 02:45 PM
biezom biezom is offline
Senior Member
 
Join Date: Sep 2014
Posts: 1,025
biezom is on a distinguished road
Default

Re: Download closed captions from Hulu


Quote:
Originally Posted by Rancher View Post
Is there a way to encrypt the subtitles (.smi, .ass, .srt…)? A script or something? Thank you in advance.
hi

http://stream-recorder.com/forum/hul...es-t20120.html
Reply With Quote
  #18  
Old 10-19-2015, 03:07 PM
Rancher Rancher is offline
Junior Member
 
Join Date: Nov 2012
Posts: 29
Rancher is on a distinguished road
Default

Re: Download closed captions from Hulu


I should have started a new topic, sorry. Encrypting, not decrypting the subtitles. I want to protect some of the subs I have, similar to what Hulu or Crunchyroll did.
Reply With Quote
Reply Post New Thread
Tags: ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 11:34 AM.


Powered by All-streaming-media.com; 2006-2011
vB forum hacked with Zoints add-ons