Пример #1
0
    def get(self, request, format=None):
        showid = request.GET.get('showid')
        epid = request.GET.get('epid')
        # print(request.GET.get('epid'))
        showinfo = apigrabber.createdetails(showid)
        otherepisodes = showinfo["posts"]
        index = otherepisodes.index((item for item in otherepisodes if item["id"] == epid).next())
        prevep = otherepisodes[index + 1]
        links = apigrabber.getstreams(prevep["id"])
        bestq = None
        for link in links:
            if not bestq:
                quality = apigrabber.find_between(link["name"], "Video ", " (")
                source = "normal"

                if quality.encode('utf-8') == "1080p":
                    bestq = link["type"]
                elif quality.encode('utf-8') == "720p":
                    bestq = link["type"]
                elif quality.encode('utf-8') == "480p":
                    bestq = link["type"]
                elif quality.encode('utf-8') == "360p":
                    bestq = link["type"]
                elif link["name"].startswith("Google Direct"):
                    bestq = link["type"]
        data = apigrabber.getstreams(prevep["id"])

        url = urllib.unquote((item for item in data if item["type"] == int(bestq)).next()["link"]).decode('utf8')
        # print(index)

        if request.user.is_authenticated():
            user = User.objects.get(pk=request.user.id)
            showname = showinfo["title"]
            epname = otherepisodes[index]["title"]
            w = watched(user=request.user.username, epid=epid, epname=epname.encode('utf-8').strip(), showid=showid,
                        showname=showname.encode('utf-8').strip())

            try:
                watched.objects.get(user=request.user.username,
                                    epid=epid,
                                    epname=epname.encode('utf-8').strip(),
                                    showid=showid,
                                    showname=showname.encode('utf-8').strip())

                # if we get this far, we have an exact match for this form's data
            except watched.DoesNotExist:
                # because we didn't get a match
                w.save()
                pass
        data = {
            "shows": {'prevepid': prevep["id"], 'link': url, 'title': prevep["title"], "source": source,
                      "type": bestq}}
        return Response(data)
Пример #2
0
 def get(self, request, format=None):
     id = request.GET.get('id')
     dict = apigrabber.createdetails(id)
     data = {
         "show":
             {
                 "desc": dict["desc"],
                 "rating": dict['rating'],
                 "startyear": dict['startyear'],
                 "title": dict['title'].replace(u'\xa0', ' ').decode("utf-8","ignore").encode('utf-8').strip(),
                 "poster": sslimage(dict['poster']),
                 "state": dict['state'],
                 "genre": dict['genre'],
                 'posts': dict["posts"]
             }
     }
     return Response(data)
Пример #3
0
def play(request, epid, streamid, showid):
    data = apigrabber.getstreams(epid)
    showinfo = apigrabber.createdetails(showid)
    otherepisodes = showinfo["posts"]
    index = otherepisodes.index((item for item in otherepisodes if item["id"] == epid).next())

    nextep = False
    prevep = False
    isshow = False
    show = showinfo["title"].encode('utf-8').strip()
    poster = showinfo["poster"]

    if len(otherepisodes) > 3:
        eptitle = otherepisodes[1]['title'].encode('utf-8').strip().replace(u'\xa0', u' ')
        if len(otherepisodes) == index + 1:
            print("first episode")
        else:
            prevep = otherepisodes[index + 1]
        if apigrabber.find_between(eptitle, "S", "E"):
            isshow = True
        if otherepisodes[index - 1]:
            nextep = otherepisodes[index - 1]

    showid = showid
    if isshow:
        pagename = otherepisodes[index]['title'].encode('utf-8').strip()
    else:
        pagename = show

    isplay = True
    post = data[int(streamid)]
    isyt = False
    if post["link"].startswith("GoogleDrive"):
        isyt = True

    return render(request, 'gui/play.html', {'title': id,
                                             "isplay": isplay,
                                             "id": epid,
                                             "poster": poster,
                                             "pagename": pagename,
                                             "isyt": isyt,
                                             "post": post,
                                             "next": nextep, "prev": prevep, "show": show, "showid": showid,
                                             "isshow": isshow})
Пример #4
0
    def get(self, request, format=None):
        updated = False
        user = request.user
        isFavourite = False
        showid = request.GET.get('id')
        dict = apigrabber.createdetails(showid)
        isshow = False
        if len(dict["posts"]) >= 10:
            if apigrabber.find_between(dict["posts"][1]["title"], "S", "E"):
                isshow = True

        if user.is_authenticated():
            w = favourite(user=user.username,
                          showid=showid,
                          showname=dict['title'].encode('utf-8').strip(),
                          show=isshow,
                          count=len(dict["posts"]),
                          poster=dict['poster'],
                          )

            try:
                favourite.objects.get(user=user.username,
                                      showid=showid, ).delete()
                isFavourite = False


                # if we get this far, we have an exact match for this form's data
            except favourite.DoesNotExist:
                # because we didn't get a match
                w.save()
                isFavourite = True

                pass
            updated = True
        data = {
            "updated": updated,
            "Favourite": isFavourite,
        }
        return Response(data)