12-27-2019 (wasnt in git)

This commit is contained in:
Michael Nolan 2022-04-17 06:41:25 -05:00
parent 357c896b6f
commit 28db59ee93
4 changed files with 196 additions and 141 deletions

View File

@ -32,7 +32,7 @@ SetColor(RGBA(0,255,0,255),DOWNLOAD_SELECTOR);
SetColor(RGBA(128,0,128,255),DOWNLOAD_KEYBOARD_OUTLINE); SetColor(RGBA(128,0,128,255),DOWNLOAD_KEYBOARD_OUTLINE);
} }
void Yellow(){ 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_TEXTBOX_BACKGROUND);
SetColor(RGBA(255,255,255,255),DOWNLOAD_FOREGROUND_NO_SELECTOR); SetColor(RGBA(255,255,255,255),DOWNLOAD_FOREGROUND_NO_SELECTOR);
SetColor(RGBA(0,0,255,255),DOWNLOAD_FOREGROUND_SELECTOR); SetColor(RGBA(0,0,255,255),DOWNLOAD_FOREGROUND_SELECTOR);

View File

@ -1,7 +1,7 @@
#include "colors.h" #include "colors.h"
void ChannelNew(char* channel,int isuser,int download,char* date); 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 pos = 0;
int daycap=31; int daycap=31;
int monthcap=12; int monthcap=12;
@ -10,7 +10,29 @@ int monthnew=11;int daynew=15;int yearnew=2019;
int downloadnotlist=1; //1 download 0 list int downloadnotlist=1; //1 download 0 list
int coldate=0;//0 is month 1 is day 2 is year int coldate=0;//0 is month 1 is day 2 is year
GRRLIB_ttfFont* myFont; 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 willtry=0;
int videos=-1; int videos=-1;
ir_t ir; ir_t ir;
@ -62,16 +84,16 @@ fclose(f);
historyobjs++; historyobjs++;
} }
} }
#define KEYBOARD_MOVELEFT 180 #define KEYBOARD_MOVELEFT 180
#define KEYBOARD_MOVERIGHT 0 #define KEYBOARD_MOVERIGHT 0
#define KEYBOARD_MOVEUP 90 #define KEYBOARD_MOVEUP 90
#define KEYBOARD_MOVEDOWN 270 #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 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','_','-',';',' '} }; 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 charx;
int chary; int chary;
int caps; int caps;
//draw function //draw function
char* ConvertString(char*src) char* ConvertString(char*src)
@ -111,61 +133,67 @@ void PatchString(char*src)
if(src[i]=='*')src[i]=' '; if(src[i]=='*')src[i]=' ';
if(src[i]>=128)src[i]='_'; if(src[i]>=128)src[i]='_';
} }
} }
static int older_progress(void* p, static int older_progress(void* p,
double dltotal, double dlnow, double dltotal, double dlnow,
double ultotal, double ulnow) double ultotal, double ulnow)
{ {
char what2[256]; dlf* ser = ((dlf*)p);
double percent = (dlnow / dltotal) * 100; char what2[256];
int realp = (int)percent; double percent = (dlnow / dltotal) * 100;
int realp = (int)percent;
if(realp>100||realp <0){ if(realp>100||realp <0){
realp=0; realp=0;
} }
sprintf(what2,"%i%%",realp); sprintf(what2,"%i%%",realp);
GRRLIB_FillScreen(GetColor(DOWNLOAD_BACKGROUND)); 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(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(268,192+120,104,32, GetColor(DOWNLOAD_PROGRESSBAR_BACKGROUND),1);
GRRLIB_Rectangle(270,192+125,realp,22, GetColor(DOWNLOAD_PROGRESSBAR_FOREGROUND),1); GRRLIB_Rectangle(270,192+125,realp,22, GetColor(DOWNLOAD_PROGRESSBAR_FOREGROUND),1);
GRRLIB_Render(); GRRLIB_Render();
return 0; return 0;
} }
void DrawKeyBoard(int posx, int posy) { void DrawKeyBoard(int posx, int posy) {
for (int y = 0; y < 4; y++) { for (int y = 0; y < 4; y++) {
for (int x = 0; x < 11; x++) { for (int x = 0; x < 11; x++) {
if (chary == y && charx == x) { if (chary == y && charx == x) {
char sw[3]; char sw[3];
if (caps == 1) { sprintf(sw, "%c", capkey[y][x]); } if (caps == 1) { sprintf(sw, "%c", capkey[y][x]); }
else { sprintf(sw, "%c", keys[y][x]); } else { sprintf(sw, "%c", keys[y][x]); }
//normal highlight //normal highlight
GRRLIB_PrintfTTF(posx + (x * 20), posy + (y * 20), myFont, sw, 16, GetColor(DOWNLOAD_KEYBOARD_SELECT)); GRRLIB_PrintfTTF(posx + (x * 20), posy + (y * 20), myFont, sw, 16, GetColor(DOWNLOAD_KEYBOARD_SELECT));
}else { }else {
char sw[3]; char sw[3];
if (caps == 1) { sprintf(sw, "%c", capkey[y][x]); } if (caps == 1) { sprintf(sw, "%c", capkey[y][x]); }
else { sprintf(sw, "%c", keys[y][x]); } else { sprintf(sw, "%c", keys[y][x]); }
//normal highlight //normal highlight
GRRLIB_PrintfTTF(posx + (x * 20), posy + (y * 20), myFont, sw, 16, GetColor(DOWNLOAD_KEYBOARD_UNSELECT)); GRRLIB_PrintfTTF(posx + (x * 20), posy + (y * 20), myFont, sw, 16, GetColor(DOWNLOAD_KEYBOARD_UNSELECT));
} }
if(UsingIRFeatures()){ if(UsingIRFeatures()){
GRRLIB_Rectangle(posx + (x*20),posy + (y * 20),20,20,GetColor(DOWNLOAD_KEYBOARD_OUTLINE),0); GRRLIB_Rectangle(posx + (x*20),posy + (y * 20),20,20,GetColor(DOWNLOAD_KEYBOARD_OUTLINE),0);
} }
} }
} }
} }
void SetKeyFromCord(ir_t irs,int posx,int posy){ void SetKeyFromCord(ir_t irs,int posx,int posy){
for (int y = 0; y < 4; y++) { for (int y = 0; y < 4; y++) {
@ -179,69 +207,69 @@ void SetKeyFromCord(ir_t irs,int posx,int posy){
} }
} }
//control //control
char Place() { char Place() {
if (caps == 1) { if (caps == 1) {
//capital //capital
char ks = capkey[chary][charx]; char ks = capkey[chary][charx];
return ks; return ks;
} }
char ks = keys[chary][charx]; char ks = keys[chary][charx];
return ks; return ks;
} }
int GoingBack() { int GoingBack() {
if (charx == 10 && chary == 0) { if (charx == 10 && chary == 0) {
return 1; return 1;
} }
return 0; return 0;
} }
void Caps() { void Caps() {
//caps Lock //caps Lock
caps = !caps; caps = !caps;
} }
void KeyMove(int Direction) void KeyMove(int Direction)
{ {
switch (Direction) { switch (Direction) {
case KEYBOARD_MOVELEFT: case KEYBOARD_MOVELEFT:
if (charx > 0)charx--; if (charx > 0)charx--;
break; break;
case KEYBOARD_MOVERIGHT: case KEYBOARD_MOVERIGHT:
if (charx < 10)charx++; if (charx < 10)charx++;
break; break;
case KEYBOARD_MOVEUP: case KEYBOARD_MOVEUP:
if (chary > 0)chary--; if (chary > 0)chary--;
break; break;
case KEYBOARD_MOVEDOWN: case KEYBOARD_MOVEDOWN:
if (chary < 3)chary++; if (chary < 3)chary++;
break; break;
} }
} }
void DrawList() { void DrawList() {
int movover=0; int movover=0;
if(willtry) movover=98; if(willtry) movover=98;
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
if (((pos + i)-2) >= 0 && ((pos + i)-2) < videos) { if (((pos + i)-2) >= 0 && ((pos + i)-2) < videos) {
char id[13]; char id[13];
char title[500]; char title[500];
char author[500]; char author[500];
char author2[46]; char author2[46];
char title2[46]; char title2[46];
char thumbsUP[20]; char thumbsUP[20];
char thumbsDown[20]; char thumbsDown[20];
char views[20]; char views[20];
char uploadDate[20]; char uploadDate[20];
char length[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); 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(title2,sizeof(title2),"%s",title);
snprintf(author2,sizeof(author2),"%s",author); snprintf(author2,sizeof(author2),"%s",author);
PatchString(title2); PatchString(title2);
@ -250,14 +278,14 @@ void DrawList() {
if(UsingIRFeatures()){ if(UsingIRFeatures()){
o=GRRLIB_PtInRect(32+movover,32+(90*i) , 576, 90,ir.x,ir.y); 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_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), 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)+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)+36, myFont, uploadDate, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
GRRLIB_PrintfTTF(32+movover, 32 + (90 * i)+54, myFont, length, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR)); GRRLIB_PrintfTTF(32+movover, 32 + (90 * i)+54, myFont, length, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
char VLD[30]; char VLD[30];
snprintf(VLD,30,"V: %s L: %s D: %s",views,thumbsUP,thumbsDown); 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_PrintfTTF(32+movover, 32 + (90 * i) + 72, myFont, VLD, 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
if(willtry){ if(willtry){
if(!ThumbnailExists(id)){ if(!ThumbnailExists(id)){
if(!Download(ThumbnailURL(id),ThumbnailFileName(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_DrawImg (32, 32 + (90 * i) + 9, tex, 0, 0.2, 0.2, RGBA(255,255,255,255));
GRRLIB_FreeTexture(tex); GRRLIB_FreeTexture(tex);
}} }}
} }
} }
/* /*
------------------------------------------------------------------------ ------------------------------------------------------------------------
TITLE UPLOAD DATE TITLE UPLOAD DATE
UPLOADER LENGTH UPLOADER LENGTH
VIEWS L D VIEWS L D
------------------------------------------------------------------------- -------------------------------------------------------------------------
*/ */
} }
int files=0; int files=0;
@ -905,8 +933,10 @@ int Download(char* url, char* file) {
CURL* curl; CURL* curl;
curl = curl_easy_init(); curl = curl_easy_init();
int ret=1; 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_URL,url);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L); 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_PROGRESSFUNCTION, older_progress);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 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_setopt(curl,CURLOPT_FAILONERROR,1L);
curl_easy_perform(curl); curl_easy_perform(curl);
long int bytes =ftell(f); long int bytes =ftell(dr.fp);
fclose(f); fclose(dr.fp);
if(bytes==0){ if(bytes==0 && dr.fileid==0){
unlink(file); unlink(file);
ret=0; ret=0;
} }

View File

@ -1,6 +1,18 @@
#include "settings.h" #include "settings.h"
int irmode=0; 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(){ int UsingIRFeatures(){
return irmode; return irmode;
} }

View File

@ -11,9 +11,19 @@
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <curl/curl.h> #include <curl/curl.h>
#include <grrlib.h> #include <grrlib.h>
#include "FreeMonoBold_ttf.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); void OpenPlaylistFile(char* playlist);
char* OpenFile(char* fname); char* OpenFile(char* fname);
char* OpenPlaylistVideoFile(char* playlist,char* video); char* OpenPlaylistVideoFile(char* playlist,char* video);