12-27-2019 (wasnt in git)
This commit is contained in:
parent
357c896b6f
commit
28db59ee93
|
@ -32,7 +32,7 @@ SetColor(RGBA(0,255,0,255),DOWNLOAD_SELECTOR);
|
|||
SetColor(RGBA(128,0,128,255),DOWNLOAD_KEYBOARD_OUTLINE);
|
||||
}
|
||||
void Yellow(){
|
||||
SetColor(RGBA(128,128,0,255),DOWNLOAD_BACKGROUND);
|
||||
SetColor(RGBA(255,255,0,255),DOWNLOAD_BACKGROUND);
|
||||
SetColor(RGBA(255,255,255,255),DOWNLOAD_TEXTBOX_BACKGROUND);
|
||||
SetColor(RGBA(255,255,255,255),DOWNLOAD_FOREGROUND_NO_SELECTOR);
|
||||
SetColor(RGBA(0,0,255,255),DOWNLOAD_FOREGROUND_SELECTOR);
|
||||
|
|
313
source/main.c
313
source/main.c
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "colors.h"
|
||||
void ChannelNew(char* channel,int isuser,int download,char* date);
|
||||
void Channel(char* channel,int isuser,int download);
|
||||
void Channel(char* channel,int isuser,int download);
|
||||
int pos = 0;
|
||||
int daycap=31;
|
||||
int monthcap=12;
|
||||
|
@ -10,7 +10,29 @@ int monthnew=11;int daynew=15;int yearnew=2019;
|
|||
int downloadnotlist=1; //1 download 0 list
|
||||
int coldate=0;//0 is month 1 is day 2 is year
|
||||
GRRLIB_ttfFont* myFont;
|
||||
|
||||
static size_t
|
||||
WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
dlf* S=((dlf*)userp);
|
||||
size_t realsize = size * nmemb;
|
||||
DLFhandler(S,realsize);
|
||||
/* struct MemoryStruct *mem = (struct MemoryStruct *)userp;
|
||||
|
||||
char *ptr = realloc(mem->memory, mem->size + realsize + 1);
|
||||
if(ptr == NULL) {
|
||||
|
||||
printf("not enough memory (realloc returned NULL)\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
mem->memory = ptr;
|
||||
memcpy(&(mem->memory[mem->size]), contents, realsize);
|
||||
mem->size += realsize;
|
||||
mem->memory[mem->size] = 0;
|
||||
*/
|
||||
fwrite(contents,size,nmemb,S->fp);
|
||||
return realsize;
|
||||
}
|
||||
int willtry=0;
|
||||
int videos=-1;
|
||||
ir_t ir;
|
||||
|
@ -62,16 +84,16 @@ fclose(f);
|
|||
historyobjs++;
|
||||
}
|
||||
}
|
||||
#define KEYBOARD_MOVELEFT 180
|
||||
#define KEYBOARD_MOVERIGHT 0
|
||||
#define KEYBOARD_MOVEUP 90
|
||||
#define KEYBOARD_MOVEDOWN 270
|
||||
char keys[4][11] = { {'0','1','2','3','4','5','6','7','8','9','<'},{'q','w','e','r','t','y','u','i','o','p','+'},{'a','s','d','f','g','h','j','k','l','(',')'},{'z','x','c','v','b','n','m','_','-',':',' '} };
|
||||
char capkey[4][11] = { {'0','1','2','3','4','5','6','7','8','9','<'},{'Q','W','E','R','T','Y','U','I','O','P',','},{'A','S','D','F','G','H','J','K','L','[',']'},{'Z','X','C','V','B','N','M','_','-',';',' '} };
|
||||
int charx;
|
||||
int chary;
|
||||
int caps;
|
||||
|
||||
#define KEYBOARD_MOVELEFT 180
|
||||
#define KEYBOARD_MOVERIGHT 0
|
||||
#define KEYBOARD_MOVEUP 90
|
||||
#define KEYBOARD_MOVEDOWN 270
|
||||
char keys[4][11] = { {'0','1','2','3','4','5','6','7','8','9','<'},{'q','w','e','r','t','y','u','i','o','p','+'},{'a','s','d','f','g','h','j','k','l','(',')'},{'z','x','c','v','b','n','m','_','-',':',' '} };
|
||||
char capkey[4][11] = { {'0','1','2','3','4','5','6','7','8','9','<'},{'Q','W','E','R','T','Y','U','I','O','P',','},{'A','S','D','F','G','H','J','K','L','[',']'},{'Z','X','C','V','B','N','M','_','-',';',' '} };
|
||||
int charx;
|
||||
int chary;
|
||||
int caps;
|
||||
|
||||
//draw function
|
||||
|
||||
char* ConvertString(char*src)
|
||||
|
@ -111,61 +133,67 @@ void PatchString(char*src)
|
|||
if(src[i]=='*')src[i]=' ';
|
||||
if(src[i]>=128)src[i]='_';
|
||||
}
|
||||
}
|
||||
}
|
||||
static int older_progress(void* p,
|
||||
double dltotal, double dlnow,
|
||||
double ultotal, double ulnow)
|
||||
{
|
||||
char what2[256];
|
||||
double percent = (dlnow / dltotal) * 100;
|
||||
int realp = (int)percent;
|
||||
dlf* ser = ((dlf*)p);
|
||||
char what2[256];
|
||||
double percent = (dlnow / dltotal) * 100;
|
||||
int realp = (int)percent;
|
||||
if(realp>100||realp <0){
|
||||
realp=0;
|
||||
}
|
||||
|
||||
|
||||
sprintf(what2,"%i%%",realp);
|
||||
}
|
||||
|
||||
|
||||
sprintf(what2,"%i%%",realp);
|
||||
GRRLIB_FillScreen(GetColor(DOWNLOAD_BACKGROUND));
|
||||
int x = 320-(((int)GRRLIB_WidthTTF (myFont, what2,72)) / 2);
|
||||
char filenamersr[1008];
|
||||
sprintf(filenamersr,"%s",ser->fnam);
|
||||
if(ser->fileid > 0){
|
||||
sprintf(filenamersr,"%s.%i",filenamersr,ser->fileid);
|
||||
}
|
||||
int x = 320-(((int)GRRLIB_WidthTTF (myFont, what2,72)) / 2);
|
||||
GRRLIB_PrintfTTF(x, 192, myFont, what2, 72, GetColor(DOWNLOAD_PROGRESSVAL));
|
||||
|
||||
GRRLIB_PrintfTTF(32, 32, myFont, filenamersr, 24, GetColor(DOWNLOAD_PROGRESSVAL));
|
||||
GRRLIB_Rectangle(268,192+120,104,32, GetColor(DOWNLOAD_PROGRESSBAR_BACKGROUND),1);
|
||||
GRRLIB_Rectangle(270,192+125,realp,22, GetColor(DOWNLOAD_PROGRESSBAR_FOREGROUND),1);
|
||||
|
||||
GRRLIB_Render();
|
||||
return 0;
|
||||
}
|
||||
|
||||
GRRLIB_Render();
|
||||
return 0;
|
||||
}
|
||||
void DrawKeyBoard(int posx, int posy) {
|
||||
|
||||
for (int y = 0; y < 4; y++) {
|
||||
|
||||
for (int x = 0; x < 11; x++) {
|
||||
|
||||
if (chary == y && charx == x) {
|
||||
char sw[3];
|
||||
if (caps == 1) { sprintf(sw, "%c", capkey[y][x]); }
|
||||
else { sprintf(sw, "%c", keys[y][x]); }
|
||||
|
||||
//normal highlight
|
||||
GRRLIB_PrintfTTF(posx + (x * 20), posy + (y * 20), myFont, sw, 16, GetColor(DOWNLOAD_KEYBOARD_SELECT));
|
||||
|
||||
|
||||
}else {
|
||||
char sw[3];
|
||||
if (caps == 1) { sprintf(sw, "%c", capkey[y][x]); }
|
||||
else { sprintf(sw, "%c", keys[y][x]); }
|
||||
|
||||
//normal highlight
|
||||
GRRLIB_PrintfTTF(posx + (x * 20), posy + (y * 20), myFont, sw, 16, GetColor(DOWNLOAD_KEYBOARD_UNSELECT));
|
||||
|
||||
|
||||
|
||||
for (int y = 0; y < 4; y++) {
|
||||
|
||||
for (int x = 0; x < 11; x++) {
|
||||
|
||||
if (chary == y && charx == x) {
|
||||
char sw[3];
|
||||
if (caps == 1) { sprintf(sw, "%c", capkey[y][x]); }
|
||||
else { sprintf(sw, "%c", keys[y][x]); }
|
||||
|
||||
//normal highlight
|
||||
GRRLIB_PrintfTTF(posx + (x * 20), posy + (y * 20), myFont, sw, 16, GetColor(DOWNLOAD_KEYBOARD_SELECT));
|
||||
|
||||
|
||||
}else {
|
||||
char sw[3];
|
||||
if (caps == 1) { sprintf(sw, "%c", capkey[y][x]); }
|
||||
else { sprintf(sw, "%c", keys[y][x]); }
|
||||
|
||||
//normal highlight
|
||||
GRRLIB_PrintfTTF(posx + (x * 20), posy + (y * 20), myFont, sw, 16, GetColor(DOWNLOAD_KEYBOARD_UNSELECT));
|
||||
|
||||
|
||||
}
|
||||
if(UsingIRFeatures()){
|
||||
GRRLIB_Rectangle(posx + (x*20),posy + (y * 20),20,20,GetColor(DOWNLOAD_KEYBOARD_OUTLINE),0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void SetKeyFromCord(ir_t irs,int posx,int posy){
|
||||
for (int y = 0; y < 4; y++) {
|
||||
|
||||
|
@ -179,69 +207,69 @@ void SetKeyFromCord(ir_t irs,int posx,int posy){
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//control
|
||||
char Place() {
|
||||
|
||||
if (caps == 1) {
|
||||
//capital
|
||||
char ks = capkey[chary][charx];
|
||||
return ks;
|
||||
}
|
||||
char ks = keys[chary][charx];
|
||||
return ks;
|
||||
|
||||
|
||||
}
|
||||
int GoingBack() {
|
||||
if (charx == 10 && chary == 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Caps() {
|
||||
//caps Lock
|
||||
caps = !caps;
|
||||
}
|
||||
|
||||
void KeyMove(int Direction)
|
||||
{
|
||||
|
||||
switch (Direction) {
|
||||
case KEYBOARD_MOVELEFT:
|
||||
if (charx > 0)charx--;
|
||||
break;
|
||||
case KEYBOARD_MOVERIGHT:
|
||||
if (charx < 10)charx++;
|
||||
break;
|
||||
case KEYBOARD_MOVEUP:
|
||||
if (chary > 0)chary--;
|
||||
break;
|
||||
case KEYBOARD_MOVEDOWN:
|
||||
if (chary < 3)chary++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//control
|
||||
char Place() {
|
||||
|
||||
if (caps == 1) {
|
||||
//capital
|
||||
char ks = capkey[chary][charx];
|
||||
return ks;
|
||||
}
|
||||
char ks = keys[chary][charx];
|
||||
return ks;
|
||||
|
||||
|
||||
}
|
||||
int GoingBack() {
|
||||
if (charx == 10 && chary == 0) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Caps() {
|
||||
//caps Lock
|
||||
caps = !caps;
|
||||
}
|
||||
|
||||
void KeyMove(int Direction)
|
||||
{
|
||||
|
||||
switch (Direction) {
|
||||
case KEYBOARD_MOVELEFT:
|
||||
if (charx > 0)charx--;
|
||||
break;
|
||||
case KEYBOARD_MOVERIGHT:
|
||||
if (charx < 10)charx++;
|
||||
break;
|
||||
case KEYBOARD_MOVEUP:
|
||||
if (chary > 0)chary--;
|
||||
break;
|
||||
case KEYBOARD_MOVEDOWN:
|
||||
if (chary < 3)chary++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawList() {
|
||||
int movover=0;
|
||||
if(willtry) movover=98;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (((pos + i)-2) >= 0 && ((pos + i)-2) < videos) {
|
||||
char id[13];
|
||||
char title[500];
|
||||
if(willtry) movover=98;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (((pos + i)-2) >= 0 && ((pos + i)-2) < videos) {
|
||||
char id[13];
|
||||
char title[500];
|
||||
char author[500];
|
||||
char author2[46];
|
||||
char title2[46];
|
||||
char thumbsUP[20];
|
||||
char thumbsDown[20];
|
||||
char views[20];
|
||||
char uploadDate[20];
|
||||
char length[20];
|
||||
|
||||
sscanf(videoitems[(pos + i)-2], "%13s %500s %500s %20s %20s %20s %20s %20s", id, title, author, thumbsUP, thumbsDown, views, uploadDate, length);
|
||||
char title2[46];
|
||||
char thumbsUP[20];
|
||||
char thumbsDown[20];
|
||||
char views[20];
|
||||
char uploadDate[20];
|
||||
char length[20];
|
||||
|
||||
sscanf(videoitems[(pos + i)-2], "%13s %500s %500s %20s %20s %20s %20s %20s", id, title, author, thumbsUP, thumbsDown, views, uploadDate, length);
|
||||
snprintf(title2,sizeof(title2),"%s",title);
|
||||
snprintf(author2,sizeof(author2),"%s",author);
|
||||
PatchString(title2);
|
||||
|
@ -250,14 +278,14 @@ void DrawList() {
|
|||
if(UsingIRFeatures()){
|
||||
o=GRRLIB_PtInRect(32+movover,32+(90*i) , 576, 90,ir.x,ir.y);
|
||||
}
|
||||
GRRLIB_Rectangle(32,32+(90*i) , 576, 90, GetColor(DOWNLOAD_SELECTOR), o);
|
||||
GRRLIB_PrintfTTF(32+movover,32+(90*i), myFont, title2, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
|
||||
GRRLIB_PrintfTTF(32+movover, 32 + (90 * i)+18, myFont, author2, 16 ,GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
|
||||
GRRLIB_PrintfTTF(32+movover, 32 + (90 * i)+36, myFont, uploadDate, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
|
||||
GRRLIB_PrintfTTF(32+movover, 32 + (90 * i)+54, myFont, length, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
|
||||
char VLD[30];
|
||||
snprintf(VLD,30,"V: %s L: %s D: %s",views,thumbsUP,thumbsDown);
|
||||
GRRLIB_PrintfTTF(32+movover, 32 + (90 * i) + 72, myFont, VLD, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
|
||||
GRRLIB_Rectangle(32,32+(90*i) , 576, 90, GetColor(DOWNLOAD_SELECTOR), o);
|
||||
GRRLIB_PrintfTTF(32+movover,32+(90*i), myFont, title2, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
|
||||
GRRLIB_PrintfTTF(32+movover, 32 + (90 * i)+18, myFont, author2, 16 ,GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
|
||||
GRRLIB_PrintfTTF(32+movover, 32 + (90 * i)+36, myFont, uploadDate, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
|
||||
GRRLIB_PrintfTTF(32+movover, 32 + (90 * i)+54, myFont, length, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
|
||||
char VLD[30];
|
||||
snprintf(VLD,30,"V: %s L: %s D: %s",views,thumbsUP,thumbsDown);
|
||||
GRRLIB_PrintfTTF(32+movover, 32 + (90 * i) + 72, myFont, VLD, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
|
||||
if(willtry){
|
||||
if(!ThumbnailExists(id)){
|
||||
if(!Download(ThumbnailURL(id),ThumbnailFileName(id))){
|
||||
|
@ -270,20 +298,20 @@ void DrawList() {
|
|||
GRRLIB_DrawImg (32, 32 + (90 * i) + 9, tex, 0, 0.2, 0.2, RGBA(255,255,255,255));
|
||||
GRRLIB_FreeTexture(tex);
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------
|
||||
TITLE UPLOAD DATE
|
||||
UPLOADER LENGTH
|
||||
VIEWS L D
|
||||
-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
------------------------------------------------------------------------
|
||||
TITLE UPLOAD DATE
|
||||
UPLOADER LENGTH
|
||||
VIEWS L D
|
||||
-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int files=0;
|
||||
|
@ -905,8 +933,10 @@ int Download(char* url, char* file) {
|
|||
CURL* curl;
|
||||
curl = curl_easy_init();
|
||||
int ret=1;
|
||||
FILE *f = fopen(file,"wb");
|
||||
|
||||
dlf dr;
|
||||
dr.fp =fopen(file,"wb");
|
||||
sprintf(dr.fnam,"%s",file);
|
||||
dr.fileid=0;
|
||||
|
||||
curl_easy_setopt(curl,CURLOPT_URL,url);
|
||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
|
||||
|
@ -917,12 +947,15 @@ curl_easy_setopt(curl,CURLOPT_URL,url);
|
|||
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, older_progress);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA,f);
|
||||
curl_easy_setopt(curl, CURLOPT_PRIVATE,(void*)&dr);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, (void*)&dr);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA,(void*)&dr);
|
||||
curl_easy_setopt(curl,CURLOPT_FAILONERROR,1L);
|
||||
curl_easy_perform(curl);
|
||||
long int bytes =ftell(f);
|
||||
fclose(f);
|
||||
if(bytes==0){
|
||||
long int bytes =ftell(dr.fp);
|
||||
fclose(dr.fp);
|
||||
if(bytes==0 && dr.fileid==0){
|
||||
unlink(file);
|
||||
ret=0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
#include "settings.h"
|
||||
|
||||
int irmode=0;
|
||||
void DLFhandler(dlf* dl,size_t real){
|
||||
//max fat32 is 4,294,967,000 just to be safe
|
||||
size_t bytesnow = ftell(dl->fp) + real;
|
||||
|
||||
if(bytesnow >= (size_t)4294967000){
|
||||
dl->fileid++;
|
||||
char nam[1008];
|
||||
|
||||
sprintf(nam,"%s.%i",dl->fnam,dl->fileid);
|
||||
freopen(nam,"wb",dl->fp);
|
||||
}
|
||||
}
|
||||
int UsingIRFeatures(){
|
||||
return irmode;
|
||||
}
|
||||
|
|
|
@ -11,9 +11,19 @@
|
|||
#include <wiiuse/wpad.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <grrlib.h>
|
||||
#include "FreeMonoBold_ttf.h"
|
||||
|
||||
typedef struct dlf{
|
||||
FILE* fp;
|
||||
char fnam[1000];
|
||||
int fileid;
|
||||
|
||||
}dlf;
|
||||
void DLFhandler(dlf* dl,size_t real);
|
||||
void OpenPlaylistFile(char* playlist);
|
||||
char* OpenFile(char* fname);
|
||||
char* OpenPlaylistVideoFile(char* playlist,char* video);
|
||||
|
|
Loading…
Reference in New Issue