Exemplo n.º 1
0
def download_vid(sid, season, ep, title, quality):
    dp = plugin.get_setting('download_path')
    if not dp:
        dp = xbmcgui.Dialog().browse(3, 'בחר תיקיית הורדות', 'files', '', False, False, '')
        if not dp:
            plugin.notify('אנא בחרו יעד להורדת הפרק', image=ICON)
            return
    plugin.set_setting('download_path', dp)

    plugin.notify('מכין הורדה..', image=ICON)
    qualities, cookie = sdarot.get_final_video_and_cookie(sid, season, ep, choose_quality=True, download=True)

    if quality == 'None':
        q_dialog = xbmcgui.Dialog()
        q_list = list(qualities.keys())
        q_index = q_dialog.select('בחר איכות', q_list)
        if q_index == -1:
            return
        quality = q_list[q_index]
    url = qualities[quality]
    if url and cookie:
        url = sdarot.get_ip_url(url)
        def download():
            with open(dp + '{0}.S{1}.E{2}_{3}.mp4'.format(title.replace(' ', '.').replace('/', '-'), season, ep, quality + 'P'), 'wb') as f:
                download_headers = {  # Required for download speed
                    'Accept-Encoding': 'gzip, deflate, br',
                    'Cache-Control': 'no-cache',
                    'Connection': 'keep-alive',
                    'User-Agent': HEADERS['User-Agent']
                    ,'Cookie': 'Sdarot={0}'.format(cookie.get('Sdarot'), safe='')
                }

                request = urllib2.Request('http:' + url, headers=download_headers)
                response = urllib2.urlopen(request)
                total_size = response.info().get('Content-Length')

                plugin.notify('ההורדה החלה', image=ICON)

                dialog = xbmcgui.DialogProgressBG()
                dialog.create(f.name)
                dialog.update(1)
                dl = 0

                while True:
                    chunk = response.read(1024 * 30)
                    if not chunk:
                        break
                    dl += len(chunk)
                    dialog.update(100 * dl / int(total_size))
                    f.write(chunk)

                dialog.close()
                response.close()

            plugin.notify('{0} עונה {1} פרק {2} ירד בהצלחה!'.format(title, season, ep), delay=8000, image=ICON)
            return True

        thr = threading.Thread(target=download)
        thr.start()
Exemplo n.º 2
0
def choose_quality(sid, season, episode, title, title_eng, plot):
    qualities, cookie = sdarot.get_final_video_and_cookie(sid, season, episode, True)

    items = []
    for q in qualities.keys():
        label = '{0}, עונה {1}, פרק {2}, ({3}p)'.format(title, season, episode, q)
        path = plugin.url_for('watch', sid=sid, season=season, episode=episode, title=title,
                              vid=sdarot.build_final_url(qualities[q], cookie))

        item = sdarot.make_item(label, path, plot, POSTER_PREFIX + sid + '.jpg', True,
                                sid=sid, episode=episode, season=season, fav='')
        item['context_menu'].extend([('הורד פרק', 'XBMC.Container.Update({0})'.format(
            plugin.url_for('download_vid', sid=sid, season=season, ep=episode, title=title_eng, quality=q)))])
        items.append(item)

    sdarot.set_dir(items, 504, 'episodes', plugin)
    return []
Exemplo n.º 3
0
def watch(sid, season, episode, title, vid):
    if vid == 'None':  # Otherwise request was sent from choose_quality and url already exist
        vid, cookie = sdarot.get_final_video_and_cookie(sid, season, episode)

    if vid:
        item = ListItem(**{
            'label': u'פרק {0}'.format(episode),
            'path': vid,
            'thumbnail': POSTER_PREFIX + sid + '.jpg'
        })

        item.as_xbmc_listitem().setContentLookup(False)
        item.set_property('mimetype', 'video/mp4')
        item.set_property('type', 'movie')
        item.set_info('Video', {
                'Title': title,
                'Genre': u'פרק {0}, עונה {1}'.format(episode, season)
            })

        plugin.set_resolved_url(item)
    else:
        plugin.notify(msg='הייתה בעיה, נסו שוב', title='שגיאה', image=ICON)