Example #1
0
def jokoa(request, slug):
    steam_json = None
    user = request.user
    jokoa = get_object_or_404(Jokoa, publikoa_da=True, slug=slug)
    if user.is_authenticated:
        fav_game = user.likes_game(jokoa)
    try:
        if jokoa.steam_id:
            steam_json = get_urljson(
                "https://store.steampowered.com/api/appdetails?appids=" +
                str(jokoa.steam_id))[str(jokoa.steam_id)]['data']
    except:
        pass
    gameplayak = GamePlaya.objects.filter(
        jokoa=jokoa, publikoa_da=True, status='1',
        pub_date__lt=timezone.now()).order_by('-pub_date')
    if steam_json:
        gameplayak_more = len(gameplayak) > 2
        gameplayak = gameplayak[:2]
    else:
        gameplayak_more = len(gameplayak) > 4
        gameplayak = gameplayak[:4]
    txapelketak = Txapelketa.objects.filter(
        jokoa=jokoa, publikoa_da=True).order_by('-pub_date')[:3]
    berriak = Berria.objects.filter(
        jokoa=jokoa, status='1',
        pub_date__lt=timezone.now()).order_by('-pub_date')
    berriak_more = len(berriak) > 3
    berriak = berriak[:3]
    itzulpenak = jokoa.jokoitzulpena_set.all()
    return render(request, 'jokoa/jokoa.html', locals())
Example #2
0
def jokoa(request, slug):
    steam_json = None
    user = request.user
    jokoa = get_object_or_404(Jokoa, publikoa_da=True, slug=slug)
    if user.is_authenticated():
        fav_game = user.likes_game(jokoa)
    try:
        if jokoa.steam_id:
            steam_json = get_urljson("http://store.steampowered.com/api/appdetails?appids=" + str(jokoa.steam_id))[
                str(jokoa.steam_id)
            ]["data"]
    except:
        pass
    gameplayak = GamePlaya.objects.filter(
        jokoa=jokoa, publikoa_da=True, status="1", pub_date__lt=datetime.now()
    ).order_by("-pub_date")
    if steam_json:
        gameplayak = gameplayak[:2]
    else:
        gameplayak = gameplayak[:4]
    users = GamerUser.objects.filter(top_jokoak=jokoa, is_staff=False).order_by("-karma")[:6]
    terminoak = Terminoa.objects.filter(jokoa=jokoa).order_by("?")[:10]
    berriak = Berria.objects.filter(jokoa=jokoa, status="1", pub_date__lt=datetime.now()).order_by("-pub_date")[:3]
    txapelketak = Txapelketa.objects.filter(jokoa=jokoa, publikoa_da=True).order_by("-pub_date")[:3]
    return render_to_response("jokoa/jokoa.html", locals(), context_instance=RequestContext(request))
Example #3
0
def get_gameplays():
    gamers = GamerUser.objects.filter(is_gamer=True,ytube_channel__isnull=False)

    for gamer in gamers:
        user = gamer.ytube_channel[gamer.ytube_channel.rfind('/')+1:]
        channel = u'http://gdata.youtube.com/feeds/api/users/'+user+'/uploads?v=2&alt=json'
        data = get_urljson(channel)

        for video in data['feed']['entry'][:5]:
            if not GamePlaya.objects.filter(bideoa=video['media$group']['yt$videoid']['$t'],erabiltzailea=gamer).exists():
                if not AutoGamePlaya.objects.filter(bideoa=video['media$group']['yt$videoid']['$t'],erabiltzailea=gamer).exists():
                    url = ''
                    for media in video['media$group']['media$thumbnail']:
                        if media['yt$name'] == 'sddefault':
                            url = media['url']
                        elif media['yt$name'] == 'hqdefault':
                            url = media['url']
                        elif media['yt$name'] == 'default':
                            url = media['url']

                    auto = AutoGamePlaya()
                    auto.izenburua = video['title']['$t'][:64]
                    auto.slug = filters.slugify(video['title']['$t'])[:50]
                    auto.desk = video['media$group']['media$description']['$t']
                    auto.iraupena_min = time.strftime('%M', time.gmtime(int(video['media$group']['yt$duration']['seconds'])))
                    auto.iraupena_seg = time.strftime('%S', time.gmtime(int(video['media$group']['yt$duration']['seconds'])))

                    auto.argazkia = loadUrlImage(url)
                    auto.bideoa = video['media$group']['yt$videoid']['$t']
                    auto.erabiltzailea = gamer
                    auto.save()
    return True                
Example #4
0
def get_gameplays():
    gamers = GamerUser.objects.filter(is_gamer=True,ytube_channel__isnull=False)

    for gamer in gamers:
        user = gamer.ytube_channel[gamer.ytube_channel.rfind('/')+1:]
        channel = u'http://gdata.youtube.com/feeds/api/users/'+user+'/uploads?v=2&alt=json'
        print(channel)
        data = get_urljson(channel)

        for video in data['feed']['entry'][:5]:
            if not GamePlaya.objects.filter(bideoa=video['media$group']['yt$videoid']['$t'],erabiltzailea=gamer).exists():
                if not AutoGamePlaya.objects.filter(bideoa=video['media$group']['yt$videoid']['$t'],erabiltzailea=gamer).exists():
                    url = ''
                    for media in video['media$group']['media$thumbnail']:
                        if media['yt$name'] == 'sddefault':
                            url = media['url']
                        elif media['yt$name'] == 'hqdefault':
                            url = media['url']
                        elif media['yt$name'] == 'default':
                            url = media['url']

                    auto = AutoGamePlaya()
                    auto.izenburua = video['title']['$t'][:64]
                    auto.slug = filters.slugify(video['title']['$t'])[:50]
                    auto.desk = video['media$group']['media$description']['$t']
                    auto.iraupena_min = time.strftime('%M', time.gmtime(int(video['media$group']['yt$duration']['seconds'])))
                    auto.iraupena_seg = time.strftime('%S', time.gmtime(int(video['media$group']['yt$duration']['seconds'])))

                    auto.argazkia = loadUrlImage(url)
                    auto.bideoa = video['media$group']['yt$videoid']['$t']
                    auto.erabiltzailea = gamer
                    auto.save()
    return True                
Example #5
0
def index(request):
    topjokoak = GamerUser.objects.values('top_jokoak__izena', 'top_jokoak__bertsioa', 'top_jokoak__logoa', 'top_jokoak__slug').annotate(Count('top_jokoak')).order_by('-top_jokoak__count', '-top_jokoak__izena')[:10]
    jokoak = Jokoa.objects.filter(publikoa_da=True).order_by("izena", "bertsioa")
    last_jokoak = Jokoa.objects.filter(publikoa_da=True).order_by("-id")[:10]
    euskaljokoak = EuskarazkoJokoa.objects.filter(publikoa_da=True).order_by('-pub_date')[:5]
    try:
        if last_jokoak[0].steam_id:
            steam_json = get_urljson("http://store.steampowered.com/api/appdetails?appids=" + str(last_jokoak[0].steam_id))[str(last_jokoak[0].steam_id)]['data']
    except:
        pass
    return render(request, 'jokoa/index.html', locals())
Example #6
0
def index(request):
    topjokoak = (
        GamerUser.objects.values("top_jokoak__izena", "top_jokoak__bertsioa", "top_jokoak__logoa", "top_jokoak__slug")
        .annotate(Count("top_jokoak"))
        .order_by("-top_jokoak__count", "-top_jokoak__izena")[:10]
    )
    jokoak = Jokoa.objects.filter(publikoa_da=True).order_by("izena", "bertsioa")
    last_jokoak = Jokoa.objects.filter(publikoa_da=True).order_by("-id")[:10]
    try:
        if last_jokoak[0].steam_id:
            steam_json = get_urljson(
                "http://store.steampowered.com/api/appdetails?appids=" + str(last_jokoak[0].steam_id)
            )[str(last_jokoak[0].steam_id)]["data"]
    except:
        pass
    return render_to_response("jokoa/index.html", locals(), context_instance=RequestContext(request))
Example #7
0
def set_user_whitelist(user,nick=None):
    if user:
        ml = None
        if MC_Whitelist.objects.filter(user=user).exists() and nick:
            ml = MC_Whitelist.objects.get(user=user)
            ml.mc_user = nick
        else:
            if JokuPlataforma.objects.filter(user=user, plataforma='minecraft').exists():
                ml = MC_Whitelist()
                ml.mc_user = JokuPlataforma.objects.filter(user=user, plataforma='minecraft')[0].nick
                ml.user = user

        if ml:
            uuid = get_urljson('https://api.mojang.com/users/profiles/minecraft/'+ml.mc_user)
            if uuid:
                ml.uuid = uuid['id']
            ml.save()
            return True
    return False
Example #8
0
def index(request):
    topjokoak = GamerUser.objects.values(
        'top_jokoak__izena', 'top_jokoak__bertsioa', 'top_jokoak__logoa',
        'top_jokoak__slug').annotate(Count('top_jokoak')).order_by(
            '-top_jokoak__count', '-top_jokoak__izena')[:10]
    jokoak = Jokoa.objects.filter(
        publikoa_da=True).select_related('logoa').order_by(
            "izena", "bertsioa").select_related('logoa')
    last_jokoak = Jokoa.objects.filter(
        publikoa_da=True).select_related('logoa').order_by("-id")[:10]
    euskaljokoak = EuskarazkoJokoa.objects.filter(
        publikoa_da=True).select_related('jokoa__logoa').order_by(
            '-pub_date')[:5]
    try:
        if last_jokoak[0].steam_id:
            steam_json = get_urljson(
                "https://store.steampowered.com/api/appdetails?appids=" +
                str(last_jokoak[0].steam_id))[str(
                    last_jokoak[0].steam_id)]['data']
    except:
        pass
    return render(request, 'jokoa/index.html', locals())