Hallo!
Ich hab eine Python Funktion die ich gerne nach C# oder vb.net übersetzen möchte..
..als Ausgabe bekomme ich bei der SHA1 Erzeugung einen 40-stelligen Hexadezimalcode..wenn ich das jedoch nach vb.net übersetze ist der Hexadezimalcode um ein vielfaches längerVielleicht kann mir ja jemand bei der Übersetzung helfen!?
Python Funktion:
vb.net Funktion:
Aufrufen tu ich die Funktion mit:
_playVideo("5474102", "http://www.7tv.de/galileo/2018154-mittwoch-helfer-oder-last-roboter-als-familienmitglieder-ganze-folge")
Ich hab eine Python Funktion die ich gerne nach C# oder vb.net übersetzen möchte..
..als Ausgabe bekomme ich bei der SHA1 Erzeugung einen 40-stelligen Hexadezimalcode..wenn ich das jedoch nach vb.net übersetze ist der Hexadezimalcode um ein vielfaches längerVielleicht kann mir ja jemand bei der Übersetzung helfen!?
Python Funktion:
Python-Quellcode
- def playvideo(video_id, client_location, source_id=None):
- from hashlib import sha1
- adaptivaddon=xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "Addons.GetAddonDetails", "params": {"addonid": "inputstream.adaptive", "properties": ["enabled"]}}')
- struktur = json.loads(adaptivaddon)
- debug("adaptivaddon struktur :")
- debug(struktur)
- is_type=""
- if not "error" in struktur.keys() :
- if struktur["result"]["addon"]["enabled"]==True:
- is_type="inputstream.adaptive"
- if is_type=="":
- adaptivaddon=xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "Addons.GetAddonDetails", "params": {"addonid": "inputstream.mpd", "properties": ["enabled"]}}')
- struktur = json.loads(adaptivaddon)
- if not "error" in struktur.keys() :
- if struktur["result"]["addon"]["enabled"]==True:
- is_type="inputstream.mpd"
- if is_type=="":
- access_token = 'h''b''b''t''v'
- salt = '0''1''r''e''e''6''e''L''e''i''w''i''u''m''i''e''7''i''e''V''8''p''a''h''g''e''i''T''u''i''3''B'
- client_name='h''b''b''t''v'
- else:
- access_token = 'seventv-web'
- salt = '01!8d8F_)r9]4s[qeuXfP%'
- client_name=''
- # dialog = xbmcgui.Dialog()
- #nr=dialog.ok("Inputstream", "Inputstream fehlt")
- #return ""
- print "is_type :"+is_type
- if source_id is None:
- source_id=0
- json_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s?' \
- 'access_token=%s&client_location=%s&client_name=%s' \
- % (video_id, access_token, client_location, client_name)
- json_data = geturl(json_url)
- json_data = json.loads(json_data)
- print json_data
- print "........................"
- if not is_type=="":
- for stream in json_data['sources']:
- if stream['mimetype']=='application/dash+xml':
- if int(source_id) < int(stream['id']):
- source_id = stream['id']
- print source_id
- else:
- #debug("Protected : "+json_data["is_protected"])
- if json_data["is_protected"]==True:
- xbmc.executebuiltin('Notification("Inputstream", "DRM geschützte Folgen gehen nur mit Inputstream")')
- return
- else:
- for stream in json_data['sources']:
- if stream['mimetype']=='video/mp4':
- if int(source_id) < int(stream['id']):
- source_id = stream['id']
- print source_id
- client_id_1 = salt[:2] + sha1(
- ''.join([str(video_id), salt, access_token, client_location, salt, client_name]).encode(
- 'utf-8')).hexdigest()
- json_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources?' \
- 'access_token=%s&client_location=%s&client_name=%s&client_id=%s' \
- % (video_id, access_token, client_location, client_name, client_id_1)
- json_data = geturl(json_url)
- json_data = json.loads(json_data)
- print json_data
- print "........................"
- server_id = json_data['server_id']
- #client_name = 'kolibri-1.2.5'
- client_id = salt[:2] + sha1(''.join([salt, video_id, access_token, server_id,client_location, str(source_id), salt, client_name]).encode('utf-8')).hexdigest()
- url_api_url = 'http://vas.sim-technik.de/vas/live/v2/videos/%s/sources/url?%s' % (video_id, urllib.urlencode({
- 'access_token': access_token,
- 'client_id': client_id,
- 'client_location': client_location,
- 'client_name': client_name,
- 'server_id': server_id,
- 'source_ids': str(source_id),
- }))
- print "url_api_url :"+url_api_url
- json_data = geturl(url_api_url)
- json_data = json.loads(json_data)
- debug ("---------------------------")
- debug( json_data)
- debug( "........................")
- max_id=0
- for stream in json_data["sources"]:
- ul=stream["url"]
- try:
- sid=re.compile('-tp([0-9]+).mp4', re.DOTALL).findall(ul)[0]
- id=int(sid)
- if max_id<id:
- max_id=id
- data=ul
- except:
- data=ul
- #data=json_data["sources"][-1]["url"]
- userAgent = 'User-Agent=Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36'
- addon_handle = int(sys.argv[1])
- listitem = xbmcgui.ListItem(path=data+"|"+userAgent)
- #listitem.setProperty('inputstream.mpd.license_type', 'com.widevine.alpha')
- #listitem.setProperty('inputstream.mpd.license_type', 'com.widevine.alpha')
- listitem.setProperty(is_type+".license_type", "com.widevine.alpha")
- listitem.setProperty(is_type+".manifest_type", "mpd")
- listitem.setProperty('inputstreamaddon', is_type)
- try:
- lic=json_data["drm"]["licenseAcquisitionUrl"]
- token=json_data["drm"]["token"]
- listitem.setProperty(is_type+'.license_key', lic +"?token="+token+"|"+userAgent+"|R{SSM}|")
- except:
- pass
- #listitem.setProperty('inputstreamaddon', 'inputstream.mpd')
- xbmcplugin.setResolvedUrl(addon_handle, True, listitem)
- #print "Daten lic :"+lic
- #print "Daten token :"+token
- #print "Daten data :"+data
- return ""
vb.net Funktion:
VB.NET-Quellcode
- Private Function _playVideo(ByVal video_id As String, ByVal client_location As String, Optional ByVal source_id As String = Nothing)
- 'Get JSON for sourceID
- Dim json_url = "http://vas.sim-technik.de/vas/live/v2/videos/" & video_id & "?access_token=" & access_token & "&client_location=" & client_location & "&client_name=" & client_name
- Dim _jsonString As String = Nothing
- Using httpClient As WebClient = New WebClient()
- _jsonString = httpClient.DownloadString(json_url)
- End Using
- Dim _json As JSON_Source_ID = _json_CreateFromString(Of JSON_Source_ID)(_jsonString)
- 'Read sourceID out of JSON
- source_id = 0
- For Each _source As Source In _json.sources
- If _source.mimetype = "application/dash+xml" Then
- If source_id < _source.id Then
- source_id = _source.id
- End If
- End If
- Next
- Using sha1 As System.Security.Cryptography.SHA1CryptoServiceProvider = New System.Security.Cryptography.SHA1CryptoServiceProvider
- Dim bytesToHash() As Byte = Encoding.UTF8.GetBytes(video_id & salt & access_token & client_location & salt & client_name)
- Dim client_id_1 As String = HexStringFromBytes(bytesToHash)
- Debug.WriteLine(client_id_1)
- End Using
- End Function
Aufrufen tu ich die Funktion mit:
_playVideo("5474102", "http://www.7tv.de/galileo/2018154-mittwoch-helfer-oder-last-roboter-als-familienmitglieder-ganze-folge")