Beispiel #1
0
def check_device_id():
    device_id = ADDON.getSetting(id='deviceId')
    amazon_device = 'Amazon'
    amazon_device = amazon_device.encode("hex")
    old_asus = 'ASUS'
    old_asus = old_asus.encode("hex")
    if amazon_device in device_id or old_asus in device_id:
        sony = SONY()
        sony.logout()
        device_id = ''
    
    if device_id == '':
        create_device_id()
Beispiel #2
0
def check_device_id():
    device_id = ADDON.getSetting(id='deviceId')
    amazon_device = 'Amazon'
    amazon_device = amazon_device.encode("hex")
    old_asus = 'ASUS'
    old_asus = old_asus.encode("hex")
    if amazon_device in device_id or old_asus in device_id:
        sony = SONY()
        sony.logout()
        device_id = ''

    if device_id == '':
        create_device_id()
def check_device_id():
    DEVICE_ID = ADDON.getSetting(id='deviceId')
    amazon_device = 'Amazon'
    amazon_device = amazon_device.encode("hex")
    old_asus = 'ASUS'
    old_asus = old_asus.encode("hex")
    if amazon_device in DEVICE_ID or old_asus in DEVICE_ID:
        sony = SONY()
        sony.logout()
        DEVICE_ID = ''

    if DEVICE_ID == '':
        create_device_id()
        DEVICE_ID = ADDON.getSetting(id='deviceId')
Beispiel #4
0
def get_stream(url, airing_id, channel_id, program_id, series_id, tms_id,
               title, plot, icon):
    headers = {
        'Accept': '*/*',
        'Content-type': 'application/x-www-form-urlencoded',
        'Origin': 'https://vue.playstation.com',
        'Accept-Language': 'en-US,en;q=0.8',
        'Referer': 'https://vue.playstation.com/watch/live',
        'Accept-Encoding': 'gzip, deflate, br',
        'User-Agent': UA_ANDROID_TV,
        'Connection': 'Keep-Alive',
        'Host': 'media-framework.totsuko.tv',
        'reqPayload': ADDON.getSetting(id='EPGreqPayload'),
        'X-Requested-With': 'com.snei.vue.android'
    }

    r = requests.get(url,
                     headers=headers,
                     cookies=load_cookies(),
                     verify=VERIFY)
    json_source = r.json()
    stream_url = json_source['body']['video']
    headers = '|User-Agent='
    headers += 'Adobe Primetime/1.4 Dalvik/2.1.0 (Linux; U; Android 6.0.1 Build/MOB31H)'
    headers += '&Cookie=reqPayload=' + urllib.quote('"' + ADDON.getSetting(
        id='EPGreqPayload') + '"')
    listitem = xbmcgui.ListItem()

    # Checks to see if VideoPlayer info is already saved. If not then info is loaded from stream link
    if xbmc.getCondVisibility('String.IsEmpty(ListItem.Title)'):
        listitem = xbmcgui.ListItem(title, plot, thumbnailImage=icon)
        listitem.setInfo(type="Video",
                         infoLabels={
                             'title': title,
                             'plot': plot
                         })
        listitem.setMimeType("application/x-mpegURL")

    else:
        listitem = xbmcgui.ListItem()
        listitem.setMimeType("application/x-mpegURL")

    inputstreamCOND = str(
        json_source['body']['dai_method']
    )  # Checks whether stream method is "mlbam" or "freewheel" or "none"

    if inputstreamCOND != 'freewheel' and xbmc.getCondVisibility(
            'System.HasAddon(inputstream.adaptive)'
    ):  #Inputstream doesn't seem to work when dai method is "freewheel"
        stream_url = json_source['body'][
            'video_alt']  # Uses alternate Sony stream to prevent Inputstream adaptive from crashing
        listitem.setProperty('inputstreamaddon', 'inputstream.adaptive')
        listitem.setProperty('inputstream.adaptive.manifest_type', 'hls')
        listitem.setProperty('inputstream.adaptive.stream_headers', headers)
        listitem.setProperty('inputstream.adaptive.license_key', headers)
    else:
        stream_url += headers

    listitem.setPath(stream_url)

    xbmcplugin.setResolvedUrl(addon_handle, True, listitem)

    # Seek to time

    # Give the stream sometime to start before checking
    monitor = xbmc.Monitor()
    monitor.waitForAbort(10)
    watched = 'false'
    play_time = 0
    mark_watched = -1
    xbmc.log("Is playing video? " + str(xbmc.Player().isPlayingVideo()))
    while xbmc.Player().isPlayingVideo() and not monitor.abortRequested():
        xbmc.log("Still playing...")
        play_time = str(xbmc.Player().getTime(
        ))  # Get timestamp of video from VideoPlayer to save as resume time
        mark_watched = xbmc.Player().getTotalTime(
        )  # Get the total time of video playing
        monitor.waitForAbort(3)
    xbmc.log("We're done, write info back to ps servers!!!")
    int_time = int(
        float(play_time))  # Convert VideoPlayer seconds from float to int
    res_time = time.strftime(
        "%H:%M:%S",
        time.gmtime(int_time))  # Convert seconds to 00:00:00 resume time
    cur_time = datetime.now().strftime("%Y-%m-%dT%H:%M:%S:%SZ")

    if 0 < (mark_watched - int_time
            ) <= 120:  # Mark video as watched if less than 2 minutes are left
        watched = 'true'

    sony = SONY()
    sony.put_resume_time(airing_id, channel_id, program_id, series_id, tms_id,
                         res_time, cur_time, watched)
Beispiel #5
0
from sony import SONY
from muxmanager import MuxManager

import time
import webservice

TAG = "Main: "
#makes sure we have preferences etc and logs in to sony; also allows us to retrieve the channel list
s = SONY()

muxManager = MuxManager(s)

#initialization
muxManager.generate_playlist()
muxManager.generate_pipe_shell_file()

#create and start the web service
web_server = webservice.PSVueProxyWebService(s, muxManager)
web_server.start()


#could use this main loop to keep the m3u file updated
while True:
    try:
        time.sleep(5)
    except KeyboardInterrupt:
        print("Keyboard Interrupt")
        web_server.stop()
        web_server.join(0)
        break
def get_stream(url, airing_id, channel_id, program_id, series_id, tms_id,
               title, plot):
    headers = {
        'Accept': '*/*',
        'Content-type': 'application/x-www-form-urlencoded',
        'Origin': 'https://vue.playstation.com',
        'Accept-Language': 'en-US,en;q=0.8',
        'Referer': 'https://vue.playstation.com/watch/live',
        'Accept-Encoding': 'gzip, deflate, br',
        'User-Agent': UA_ANDROID_TV,
        'Connection': 'Keep-Alive',
        'Host': 'media-framework.totsuko.tv',
        'reqPayload': ADDON.getSetting(id='EPGreqPayload'),
        'X-Requested-With': 'com.snei.vue.android'
    }

    r = requests.get(url,
                     headers=headers,
                     cookies=load_cookies(),
                     verify=VERIFY)
    json_source = r.json()
    stream_url = json_source['body']['video']
    headers = '|User-Agent='
    headers += 'Adobe Primetime/1.4 Dalvik/2.1.0 (Linux; U; Android 6.0.1 Build/MOB31H)'
    headers += '&Cookie=reqPayload=' + urllib.quote('"' + ADDON.getSetting(
        id='EPGreqPayload') + '"')
    listitem = xbmcgui.ListItem()

    # Checks to see if VideoPlayer info is already saved. If not then info is loaded from stream link
    if xbmc.getCondVisibility('String.IsEmpty(ListItem.Title)'):
        listitem = xbmcgui.ListItem(title, plot)
        listitem.setInfo(type="Video",
                         infoLabels={
                             'title': title,
                             'plot': plot
                         })
        listitem.setMimeType("application/x-mpegURL")

    else:
        listitem = xbmcgui.ListItem()
        listitem.setMimeType("application/x-mpegURL")

    if xbmc.getCondVisibility('System.HasAddon(inputstream.adaptive)'):
        stream_url = json_source['body'][
            'video_alt']  # Uses alternate Sony stream to prevent Inputstream adaptive from crashing
        listitem.setProperty('inputstreamaddon', 'inputstream.adaptive')
        listitem.setProperty('inputstream.adaptive.manifest_type', 'hls')
        listitem.setProperty('inputstream.adaptive.stream_headers', headers)
        listitem.setProperty('inputstream.adaptive.license_key', headers)

    else:
        stream_url += headers

    listitem.setPath(stream_url)

    xbmcplugin.setResolvedUrl(addon_handle, True, listitem)

    # Seek to time

    #Give the stream sometime to start before checking

    monitor = xbmc.Monitor()
    monitor.waitForAbort(10)
    xbmc.log("Is playing video? " + str(xbmc.Player().isPlayingVideo()))
    while xbmc.Player().isPlayingVideo() and not monitor.abortRequested():
        xbmc.log("Still playing...")
        monitor.waitForAbort(3)

    xbmc.log("We're done, write info back to ps servers!!!")
    sony = SONY()
    sony.put_resume_time(airing_id, channel_id, program_id, series_id, tms_id)
Beispiel #7
0
def get_stream(url, airing_id, channel_id, program_id, series_id, tms_id, title, plot, icon):
    headers = {
        'Accept': '*/*',
        'Content-type': 'application/x-www-form-urlencoded',
        'Origin': 'https://vue.playstation.com',
        'Accept-Language': 'en-US,en;q=0.8',
        'Referer': 'https://vue.playstation.com/watch/live',
        'Accept-Encoding': 'gzip, deflate, br',
        'User-Agent': UA_ANDROID_TV,
        'Connection': 'Keep-Alive',
        'Host': 'media-framework.totsuko.tv',
        'reqPayload': ADDON.getSetting(id='EPGreqPayload'),
        'X-Requested-With': 'com.snei.vue.android'
    }

    r = requests.get(url, headers=headers, cookies=load_cookies(), verify=VERIFY)
    json_source = r.json()
    stream_url = json_source['body']['video']
    headers = '|User-Agent='
    headers += 'Adobe Primetime/1.4 Dalvik/2.1.0 (Linux; U; Android 6.0.1 Build/MOB31H)'
    headers += '&Cookie=reqPayload=' + urllib.quote('"' + ADDON.getSetting(id='EPGreqPayload') + '"')
    listitem = xbmcgui.ListItem()

    # Checks to see if VideoPlayer info is already saved. If not then info is loaded from stream link
    if xbmc.getCondVisibility('String.IsEmpty(ListItem.Title)'):
        listitem = xbmcgui.ListItem(title, plot, thumbnailImage=icon)
        listitem.setInfo(type="Video", infoLabels={'title': title, 'plot': plot})
        listitem.setMimeType("application/x-mpegURL")
    else:
        listitem = xbmcgui.ListItem()
        listitem.setMimeType("application/x-mpegURL")

    if xbmc.getCondVisibility('System.HasAddon(inputstream.adaptive)'):
        stream_url = json_source['body']['video_alt']
        listitem.setProperty('inputstreamaddon', 'inputstream.adaptive')
        listitem.setProperty('inputstream.adaptive.manifest_type', 'hls')
        listitem.setProperty('inputstream.adaptive.stream_headers', headers)
        listitem.setProperty('inputstream.adaptive.license_key', headers)
    else:
        stream_url += headers

    listitem.setPath(stream_url)

    xbmcplugin.setResolvedUrl(addon_handle, True, listitem)

    # Seek to time

    # Give the stream sometime to start before checking
    monitor = xbmc.Monitor()
    monitor.waitForAbort(10)
    watched = 'false'
    play_time = 0
    mark_watched = -1
    xbmc.log("Is playing video? " + str(xbmc.Player().isPlayingVideo()))
    while xbmc.Player().isPlayingVideo() and not monitor.abortRequested():
        xbmc.log("Still playing...")
        play_time = str(xbmc.Player().getTime())  # Get timestamp of video from VideoPlayer to save as resume time
        mark_watched = xbmc.Player().getTotalTime()  # Get the total time of video playing
        monitor.waitForAbort(3)
    xbmc.log("We're done, write info back to ps servers!!!")
    int_time = int(float(play_time))  # Convert VideoPlayer seconds from float to int
    res_time = time.strftime("%H:%M:%S", time.gmtime(int_time))  # Convert seconds to 00:00:00 resume time
    cur_time = datetime.now().strftime("%Y-%m-%dT%H:%M:%S:%SZ")

    if 0 < (mark_watched - int_time) <= 120:  # Mark video as watched if less than 2 minutes are left
        watched = 'true'

    sony = SONY()
    sony.put_resume_time(airing_id, channel_id, program_id, series_id, tms_id, res_time, cur_time, watched)