Example #1
0
def download(request):
    result = get_navbar(request)

    data = json.loads(open(DATA_ROOT + 'genuine.json').read())
    product = request.GET.get('product', 'windows')

    for navigation in data['navigation']:
        for item in navigation['item']:
            if item['id'] == product:
                navigation.update({'active': True})
                break

    items = []
    for software in data['software']:
        if software['id'] == product:
            for edition in software['edition']:
                edition.update({
                    'channel': {
                        'name': data['channel'][edition['channel']['type']]['name'],
                        'url': data['channel'][edition['channel']['type']]['url'] + edition['channel']['id']
                    }
            })

            items.append(software)

    result.update({'navigation': data['navigation'], 'items': items})

    return render_to_response('genuine/download.html', result)
Example #2
0
def download(request):
    result = get_navbar(request)

    # Catalog > Product > Version > Edition > Item
    product = request.GET.get('product', None)
    if product:
        current = Catalog.objects.get(id=UUID(bytes=urlsafe_base64_decode(product)))
    else:
        current = Catalog.objects.filter(name='Windows')[0] # HARD CODING

    catalogs = []
    for catalog in Catalog.objects.filter(parent=None):
        active = False
        products = []
        for product in catalog.catalog_set.all():
            products.append({'name': product.name, 'id': urlsafe_base64_encode(product.id.bytes)})
            if not active and product == current:
                active = True
        catalogs.append({'name': catalog.name, 'products': products, 'active': active})

    result.update({'catalogs': catalogs})

    versions = []
    for version in current.catalog_set.order_by('-order'):
        editions = []
        for edition in version.catalog_set.all():
            items = []
            for item in edition.item_set.all():
                items.append({'name': item.name, 'file': item.file_id})
            editions.append({'name': edition.name, 'items': items})
        versions.append({'id': version.id, 'name': version.name, 'editions': editions})

    result.update({'versions': versions})

    return render_to_response('genuine/download.html', result)
Example #3
0
def tv(request):
    result = get_navbar(request)
    get_active_channel(result)

    channel = get_object_or_404(Channel, channel=request.GET.get("channel", "CCTV-1"))
    for group in result["channels"]:
        for item in group["channels"]:
            if item["channel"] == channel.channel:
                group.update({"active": True})
                result.update({"channel": item})
                break

    guide = Guide.objects.filter(channel=channel)

    noon = time(12)
    am = guide.filter(time__lt=noon)
    pm = guide.filter(time__gte=noon)
    result.update({"items": {"am": am, "pm": pm}})

    now = datetime.now().time()
    index = guide.filter(time__lt=now).count() - 1
    if index < len(am):
        result.update({"current": {"am": index}})
    else:
        result.update({"current": {"pm": index - len(am)}})

    return render_to_response("iptv/tv.html", result)
Example #4
0
def index(request):
    result = get_navbar(request)

    unique_files = File.objects.order_by('md5sum', 'sha1sum').distinct('md5sum', 'sha1sum')
    total_sizes = 0
    for unique_file in unique_files:
        total_sizes += unique_file.size

    result.update({
        'file': {
            'total': File.objects.count(),
            'unique': len(unique_files),
            'size': file_size(total_sizes),
        },
        'download': {
            'today': len(Download.objects.filter(time__gte=date.today())),
            'week': len(Download.objects.filter(time__gt=date.today() - timedelta(days=6))),
            'month': len(Download.objects.filter(time__gt=date.today() - timedelta(days=29))),
        },
        'date': {
            'week': date.today() - timedelta(days=6),
            'month': date.today() - timedelta(days=29),
        },
    })

    return render_to_response('file/index.html', result)
Example #5
0
def voice_of_china(request):
    result = get_navbar(request)

    list = []
    reader = csv.reader(open(DATA_ROOT + 'voice_of_china.csv'))
    for row in reader:
        list.append({'name': row[0], 'id': row[1]})
    result.update({'items': list})
    
    return render_to_response('iptv/voice_of_china.html', result)
Example #6
0
def index(request):
    result = get_navbar(request)

    results = []
    mirrors = [
        'centos', 'epel', 'atomic', 'repoforge',
        'kali', 'kali-security', 'kali-images',
        'raspbian', 'rpi-firmware', 'rpi-kernel',
        'ubuntu-releases',
        'archlinux', 'gentoo', 'gentoo-portage',
        'mariadb',
        'cpan', 'pypi', 'rubygems',
        'cygwin', 'eclipse', 'putty',
        'android', 'qt',
        'ldp', 'lfs', 'blfs'
    ]
    for mirror in mirrors:
        if mirror in ['cpan']:
            status = '实时同步'
            style = 'success'
        else:
            status = get_value(mirror, 'status')

            if status == '-1':
                status = '正在同步'
                style = 'info'
            elif status == '-2':
                status = '正在统计'
                style = 'info'
            elif status == '0':
                status = '同步成功'
                style = 'success'
            else:
                status = '同步失败'
                style = 'danger'

        count = get_value(mirror, 'count')
        size = get_value(mirror, 'size')
        timestamp = get_value(mirror, 'timestamp')

        results.append({
            'mirror': mirror, 'status': status, 'style': style, 'count': count, 'size': file_size(int(size)), 'timestamp': timestamp
        })
    result.update({'results': results})

    return render_to_response('mirror/index.html', result)
Example #7
0
    def get_context_data(self, **kwargs):
        context = super(FileView, self).get_context_data(**kwargs)
        context.update(get_navbar(self.request))
        context.update({'id': urlsafe_base64_encode(kwargs['object'].id.bytes)})
        context.update({'key': signer.sign(get_value(self.request, kwargs['object'].id)).replace(':', '')[-33:]})
        context.update({'ip': str(get_ip(self.request))})
        context.update({'geo': get_geo(self.request)[1]})
        context.update({'speed': get_speed(self.request)})

        mimetype = kwargs['object'].mime
        if mimetype == 'application/x-iso9660-image':
            mimeicon = 'cd'
        elif mimetype.startswith('video'):
            mimeicon = 'film'
        else:
            mimeicon = 'file'
        context.update({'mimeicon': mimeicon})

        return context
Example #8
0
def tv(request):
    result = get_navbar(request)
    get_active_channel(result)

    channel = request.GET.get('channel', 'cctv1')
    for group in result['channels']:
        for item in group['channels']:
            if item['channel'] == channel:
                group.update({'active': True})
                result.update({'channel': item})
                break

    all_list = json.loads(open(DATA_ROOT + 'tv_time.json').read())
    for item in all_list:
        if item['channel'] == channel:
            list = item['list']

            am = []
            pm = []
            for item in list:
                if datetime.strptime(item['time'], '%H:%M').time().hour < 12:
                    am.append(item)
                else:
                    pm.append(item)

            playing = 0
            for index in range(len(list)):
                current = datetime.strptime(list[index]['time'], '%H:%M').time()
                now = datetime.now().time()

                if (now < current):
                    break
                else:
                    playing = index

            if playing < len(am):
                am[playing].update({'current': True})
            else:
                pm[playing - len(am)].update({'current': True})

            result.update({'items': {'am': am, 'pm': pm}})

    return render_to_response('iptv/tv.html', result)
Example #9
0
def index(request):
    result = get_navbar(request)
    result.update({'more_list': get_more_list(request)})

    results = []
    mirrors = Mirror.objects.filter(active=True).order_by('order')
    for mirror in mirrors:
        item = mirror.status

        try:
            if mirror.name in ['cpan']:
                item.status = '实时同步'
                item.style = 'success'
            elif mirror.name in ['kali', 'kali-security']:
                item.status = '被动同步'
                item.style = 'success'
            else:
                if item.status == -1:
                    item.status = '正在同步'
                    item.style = 'info'
                elif item.status == -2:
                    item.status = '正在统计'
                    item.style = 'info'
                elif item.status == 0:
                    item.status = '同步成功'
                    item.style = 'success'
                elif item.status is None:
                    item.status = '状态未知'
                    item.style = 'default'
                else:
                    item.status = '同步失败'
                    item.style = 'danger'

            results.append({
                'mirror': mirror.name, 'status': item.status, 'style': item.style, 'count': item.count, 'size': file_size(item.size), 'timestamp': item.time
            })
        except Status.DoesNotExist:
            pass

    result.update({'results': results})

    return render_to_response('mirror/index.html', result)
Example #10
0
def download(request):
    result = get_navbar(request)

    return render_to_response('dreamspark/download.html', result)
Example #11
0
def index(request):
    result = get_navbar(request)

    return render_to_response('dreamspark/index.html', result)
Example #12
0
def voice_of_china_2014(request):
    result = get_navbar(request)

    return render_to_response("iptv/voice_of_china_2014.html", result)
Example #13
0
def index(request):
    result = get_navbar(request)

    return render_to_response('genuine/index.html', result)
Example #14
0
 def get_context_data(self, **kwargs):
     context = super(MoreServicesView, self).get_context_data(**kwargs)
     context.update(get_navbar(self.request))
     return context
Example #15
0
def index(request):
    result = get_navbar(request)
    result.update({'more_service_list': get_services(request)})

    return render_to_response('www/index.html', result)
Example #16
0
 def get_context_data(self, **kwargs):
     context = super(PlayView, self).get_context_data(**kwargs)
     context.update(get_navbar(self.request))
     context.update({'path': kwargs['object'].crc32[-2:] + '/' + kwargs['object'].md5sum + kwargs['object'].sha1sum})
     return context
Example #17
0
 def get_context_data(self, **kwargs):
     context = super(FileView, self).get_context_data(**kwargs)
     context.update(get_navbar(self.request))
     context.update({'key': signer.sign(get_value(self.request, kwargs['object'].id)).replace(':', '')[-33:]})
     context.update({'ip': str(get_ip(self.request))})
     return context
Example #18
0
def configurations(request):
    result = get_navbar(request)
    return render_to_response('mirror/configurations.html', result)
Example #19
0
def worldcup_2014(request):
    result = get_navbar(request)

    return render_to_response('iptv/worldcup_2014.html', result)
Example #20
0
def index(request):
    result = get_navbar(request)
    get_active_channel(result)

    return render_to_response('iptv/index.html', result)