1-17-2020 (wasnt in git)

This commit is contained in:
Michael Nolan 2022-04-17 06:44:32 -05:00
parent 28db59ee93
commit 5d8203e27b
4 changed files with 638 additions and 207 deletions

View File

@ -37,7 +37,7 @@ LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
LIBS := -lgrrlib -lcurl -lmbedtls -lmbedx509 -lmbedcrypto -lwiisocket
LIBS += -lfreetype -lbz2
LIBS += -lpngu -lpng -ljpeg -lz -lntfs -lfat
LIBS += -lwiiuse
LIBS += -lwiikeyboard -lwiiuse
#LIBS += -lmodplay -laesnd
LIBS += -lbte -logc -lm

View File

@ -1,15 +1,36 @@
#include "colors.h"
#include <wiikeyboard/keyboard.h>
void ChannelNew(char* channel,int isuser,int download,char* date);
void Channel(char* channel,int isuser,int download);
void PLTXTSearch();
void FileList();
void DrawList();
void DrawListSearch();
int pos = 0;
int daycap=31;
int monthcap=12;
int channelsetting=-1;//-1 not enabled 0 for channel new 1 for user new 2 for channel 3 for user
int monthnew=11;int daynew=15;int yearnew=2019;
int downloadnotlist=1; //1 download 0 list
int listtype=0;//0 none 1 searchtype 2 pltxt select
int coldate=0;//0 is month 1 is day 2 is year
GRRLIB_ttfFont* myFont;
void LoadQuery(char *file);
int keysleft =0;
char buffer2[15];
void DL_IMAGES(char* name);
void keyPress_cb( char sym) {
if (sym > 31 ) {buffer2[keysleft]=sym;keysleft++;}
if (sym == 13) {buffer2[keysleft]='\n';keysleft++;}
if (sym == 8) {buffer2[keysleft]='\r';keysleft++;}
if ( sym == 0x1b) {
GRRLIB_Exit();
exit(0);
}
}
static size_t
WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
@ -38,18 +59,26 @@ int videos=-1;
ir_t ir;
char videoitems[500][1001];
int keyboard = 0;
int Download(char*, char*);
int Download2(char*, char*,int);
int Download(char* url, char* file){
return Download2(url,file,1);
}
char history[2000][40];
int historyobjs = 0;
int historyobj = -1;
int mustadd=0;
int addtopltxt=0;
char pltxt[40];
int pltxtselected=0;
void AddHistory();
void LoadHistory();
char url[40];
void PlaylistEx(char*,char*);
char url[2048];
void PlaylistEx(char*,char*,int*);
void Playlist(char* pl){
PlaylistEx(pl,"Playlist");
int i=1;
PlaylistEx(pl,"Playlist",&i);
}
void Search(char*);
void PLSearch(char*);
@ -88,14 +117,42 @@ historyobjs++;
#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','_','-',';',' '} };
char keys[5][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[5][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* StandardURL(char* src)
{
char* code=malloc((strlen(src)*3)+1);
code[0]='\0';
for(int i = 0;i<(int)strlen(src);i++){
if(src[i]=='+'){
sprintf(code,"%s%%2B",code);
}else if(src[i]==','){
sprintf(code,"%s%%2C",code);
}else if(src[i]=='('){
sprintf(code,"%s%%28",code);
}else if(src[i]==')'){
sprintf(code,"%s%%29",code);
}else if(src[i]=='['){
sprintf(code,"%s%%5B",code);
}else if(src[i]==']'){
sprintf(code,"%s%%5D",code);
}else if(src[i]==';'){
sprintf(code,"%s%%3B",code);
}else if(src[i]==' ' || src[i]=='\\' ||src[i]=='<'|| src[i]=='{'|| src[i]=='}'||src[i]=='`'||src[i]=='>'||src[i]=='|' ||src[i]=='@' || src[i]== '$' || src[i]== '!' || src[i]=='#'){
sprintf(code,"%s%%20",code);
}
else{
sprintf(code,"%s%c",code,src[i]);
}
}
return code;
}
char* ConvertString(char*src)
{
char* code=malloc((strlen(src)*3)+1);
@ -115,9 +172,39 @@ char* ConvertString(char*src)
sprintf(code,"%s%%5D",code);
}else if(src[i]==';'){
sprintf(code,"%s%%3B",code);
}else if(src[i]==' '){
}else if(src[i]==' ' || src[i]=='\\' || src[i]=='?'||src[i]=='<'|| src[i]=='{'|| src[i]=='}'||src[i]=='`'||src[i]=='&'||src[i]=='>'|| src[i]=='%' ||src[i]=='|' ||src[i]=='@' || src[i]== '$' || src[i]== '!' || src[i]=='#' || src[i]=='~' || src[i]=='/'){
sprintf(code,"%s%%20",code);
}else{
}
else{
sprintf(code,"%s%c",code,src[i]);
}
}
return code;
}
char* SString(char*src)
{
char* code=malloc((strlen(src)*3)+1);
code[0]='\0';
for(int i = 0;i<(int)strlen(src);i++){
if(src[i]=='+'){
sprintf(code,"%s+",code);
}else if(src[i]==','){
sprintf(code,"%s+",code);
}else if(src[i]=='('){
sprintf(code,"%s+",code);
}else if(src[i]==')'){
sprintf(code,"%s+",code);
}else if(src[i]=='['){
sprintf(code,"%s+",code);
}else if(src[i]==']'){
sprintf(code,"%s+",code);
}else if(src[i]==';'){
sprintf(code,"%s+",code);
}else if(src[i]==' ' || src[i]=='\\' || src[i]=='?'||src[i]=='<'|| src[i]=='{'|| src[i]=='}'||src[i]=='`'||src[i]=='&'||src[i]=='>'|| src[i]=='%' ||src[i]=='|' ||src[i]=='@' || src[i]== '$' || src[i]== '!' || src[i]=='#' || src[i]=='~' || src[i]=='/'){
sprintf(code,"%s+",code);
}
else{
sprintf(code,"%s%c",code,src[i]);
}
@ -150,22 +237,30 @@ dlf* ser = ((dlf*)p);
sprintf(what2,"%i%%",realp);
GRRLIB_FillScreen(GetColor(DOWNLOAD_BACKGROUND));
char filenamersr[1008];
sprintf(filenamersr,"%s",ser->fnam);
sprintf(filenamersr,"%s",ser->fnam2);
if(ser->fileid > 0){
sprintf(filenamersr,"%s.%i",filenamersr,ser->fileid);
}
char numb[2048];
sprintf(numb,"Item: %i",ser->fileindex);
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_PrintfTTF(32, 32, myFont, filenamersr, 18, GetColor(DOWNLOAD_PROGRESSVAL));
GRRLIB_PrintfTTF(32, 64, myFont, numb, 18, 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();
WPAD_ScanPads(); // Scan the Wii Remotes
u32 ke=WPAD_ButtonsDown(0);
if(ke & WPAD_BUTTON_HOME){
return 1;
}
return 0;
}
void DrawKeyBoard(int posx, int posy) {
for (int y = 0; y < 4; y++) {
for (int y = 0; y < 5; y++) {
for (int x = 0; x < 11; x++) {
@ -239,25 +334,41 @@ char Place() {
switch (Direction) {
case KEYBOARD_MOVELEFT:
if (charx > 0)charx--;
if (charx > 0){charx--;}else{charx=10;}
break;
case KEYBOARD_MOVERIGHT:
if (charx < 10)charx++;
if (charx < 10){charx++;}else{charx=0;}
break;
case KEYBOARD_MOVEUP:
if (chary > 0)chary--;
if (chary > 0){chary--;}else{chary=4;}
break;
case KEYBOARD_MOVEDOWN:
if (chary < 3)chary++;
if (chary < 4){chary++;}else{chary=0;}
break;
}
}
void DrawList(){
if(listtype==1){
DrawListSearch();
}else if(listtype==2){
FileList();
}
}
void FileList(){
for (int i = 0; i < 11; i++) {
if (((pos + i)-6) >= 0 && ((pos + i)-6) <= videos) {
int o=(i == 6);
GRRLIB_Rectangle(32,32+(30*i) , 576, 30, GetColor(DOWNLOAD_SELECTOR), o);
GRRLIB_PrintfTTF(32,32+(30*i), myFont,videoitems[(pos + i)-6] , 16, GetColor(DOWNLOAD_FOREGROUND_SELECTOR));
}}
}
void DrawListSearch() {
int movover=0;
if(willtry) movover=98;
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 title[500];
char author[500];
@ -318,7 +429,18 @@ int files=0;
int iswad=0;
void WPAD_ONMENU(u32 key){
if(key & WPAD_BUTTON_MINUS){
PLTXTSearch();
}
if(key & WPAD_BUTTON_PLUS){
if(listtype==2 && pos >-1 ){
//load pltxt and DoIT
sprintf(pltxt,"%s",videoitems[pos]);
pltxtselected=1;
return;
}
}
if (key & WPAD_BUTTON_2) {
SwitchIR();
}
@ -379,7 +501,7 @@ void WPAD_ONMENU(u32 key){
}
}
if (UsingIRFeatures() && (key & WPAD_BUTTON_A)){
if(pos>-1){
if(pos>-1 && listtype !=2){
int clickid=0;
int clickedtype=-1;//-1 no click 0 item 1 page up 2 page down
@ -418,6 +540,7 @@ void WPAD_ONMENU(u32 key){
}
if(GRRLIB_PtInRect(32,32+(90*4),576,90,ir.x,ir.y)){
clickid=2;
clickedtype=0;
}
@ -466,6 +589,7 @@ void WPAD_ONMENU(u32 key){
if (key & WPAD_BUTTON_A) {
if(pos>-1){
if(listtype==1){
//download
char id[13];
char title[500];
@ -480,7 +604,12 @@ void WPAD_ONMENU(u32 key){
char idTool[500];
sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",id);
Download(idTool,OpenVideoFile(filename));
}else if(listtype==2){
//load pltxt and DoIT
sprintf(pltxt,"%s",videoitems[pos]);
pltxtselected=1;
LoadQuery(pltxt);
}
}else if(pos==-1){
keyboard=1;
}
@ -588,13 +717,79 @@ if(UsingIRFeatures() && (key & WPAD_BUTTON_1)){
GRRLIB_FreeTexture (tex);
}}
}
if(UsingIRFeatures() && (key & WPAD_BUTTON_PLUS)){
int clickid=0;
int clickedtype=0;
if(pos>-1){
//-1 no click 0 item 1 page up 2 page down
//check if selected is -2
//x is always at least 32 and no more then 576+32
//y is always at least 32 and no more than 32+90
if(GRRLIB_PtInRect(32,32,576,90,ir.x,ir.y)){
clickid=-2;
clickedtype=1;
}
if(GRRLIB_PtInRect(32,32+90,576,90,ir.x,ir.y)){
clickid=-1;
clickedtype=1;
}
if(GRRLIB_PtInRect(32,32+(90*2),576,90,ir.x,ir.y)){
clickid=0;
clickedtype=1;
}
if(GRRLIB_PtInRect(32,32+(90*3),576,90,ir.x,ir.y)){
clickid=1;
clickedtype=1;
}
if(GRRLIB_PtInRect(32,32+(90*4),576,90,ir.x,ir.y)){
clickid=2;
clickedtype=1;
}
}else{
if(GRRLIB_PtInRect(150,224,340,32,ir.x,ir.y)&&pos==-1){
clickedtype=2; //not 1
}
}
if(clickedtype!=0){
char id[13];
if (((pos + clickid) >= 0 && (pos + clickid) < videos) && clickedtype==1 && pltxtselected==1) {
char id[13];
char title[500];
sscanf(videoitems[pos + clickid], "%13s %500s", id, title);
WriteFile2PL(pltxt,"vi",id,title);
}
}
}else{
if(key & WPAD_BUTTON_PLUS){
char id[13];
char title[500];
sscanf(videoitems[pos], "%13s %500s", id, title);
if (pos >= 0 && pos < videos && pltxtselected==1) {
WriteFile2PL(pltxt,"vi",id,title);
}}}}
//BROKEN BUT MAY GET FIXED use
//fixed
void LoadQuery(char *file){
int filesr=1;
FILE *f = PlaylistTXT(file);
if(f){
while(1){
@ -631,15 +826,16 @@ void LoadQuery(char *file){
char idTool[500];
sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",url2);
Download(idTool,OpenVideoFile(filenamez));
Download2(idTool,OpenVideoFile(filenamez),filesr);
}else if(strcmp("pl",type)==0){
//playlist on url2
PlaylistEx(url2,data);
PlaylistEx(url2,data,&filesr);
}else if(strcmp("dl",type)==0){
//playlist on url2
Download(url2,OpenFile(data));
Download2(url2,OpenFile(data),filesr);
}
filesr++;
}
}
@ -647,6 +843,28 @@ void LoadQuery(char *file){
}
void WPAD_KEYBOARD(u32 key) {
if(keysleft >0 && channelsetting==-1){
keysleft--;
char keyr = buffer2[keysleft];
if (!(keyr == '\r' || keyr == '\n')) {
snprintf(url, 2048, "%s%c", url, keyr);
}
else if(keyr == '\r' && keyr != '\n'){
if (strlen(url) > 0) {
url[strlen(url) - 1] = '\0';
}
}
else if(keyr == '\n' && keyr != '\r'){
goto plus;
}
mustadd=1;
}
if (key & WPAD_BUTTON_2) {
SwitchIR();
}
@ -659,7 +877,7 @@ if (key & WPAD_BUTTON_2) {
if (key & WPAD_BUTTON_1) {
//change keyboard if keyboard<4 instead of 3 LoadQuery Enabled
if(keyboard<6){
if(keyboard<9){
keyboard++;
}else{
keyboard=1;
@ -676,23 +894,32 @@ if (key & WPAD_BUTTON_2) {
}
}
if(channelsetting==-1){
if (key & WPAD_BUTTON_PLUS) {
//apply
plus:
if(mustadd==1){
AddHistory();
mustadd=0;
keyboard=0;
//keyboard=0;
}
if(keyboard==1){
Search(url);
keyboard=0;
}
if(keyboard==3){
if(keyboard==4){
if(addtopltxt==1 && pltxtselected==1){
WriteFile2PL(pltxt,"pl",url,"NOTITLE");
}else{
Playlist(url);
}
keyboard=0;
}
if(keyboard==2){
if(addtopltxt==1 && pltxtselected==1){
WriteFile2PL(pltxt,"vi",url,"NOTITLE");
}else{
char filenamez[530];
char timein[20];
time_t now = time(0);
@ -701,15 +928,9 @@ if(channelsetting==-1){
char idTool2[500];
sprintf(idTool2,"https://stark-shelf-08981.herokuapp.com/Grabber/info/%s",url);
if(Download(idTool2,Temp())){
FILE *f = fopen(Temp(),"r");
fgets(title,300,f);
fclose(f);
DeleteTemp();
PatchString(title);
}else{
sprintf(title,"NOTITLE");
}
sprintf(filenamez,"%s(%s)",title,timein);
@ -717,18 +938,55 @@ if(channelsetting==-1){
sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",url);
Download(idTool,OpenVideoFile(filenamez));
}
keyboard=0;
}
if(keyboard==4){
LoadQuery(url);
if(keyboard==5){
//LoadQuery(url);
pltxtselected = 1;
snprintf(pltxt,40,"%s.txt",url);
CreatePL(pltxt);
keyboard=0;
}
if(keyboard==6){
if(keyboard==7){
channelsetting=0;
return;
}
if(keyboard==5){
if(keyboard==8){
if (addtopltxt==1){
addtopltxt=0;
}else{
addtopltxt=1;
}
}
if(keyboard==9){
DL_IMAGES(url);
}
if(keyboard==3){
if(addtopltxt==1 && pltxtselected==1){
WriteFile2PL(pltxt,"dl",url,"NOTITLE(%s).bin");
}else{
char filenamez[530];
char timein[20];
time_t now = time(0);
strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now));
char title[300];
sprintf(title,"NOTITLE");
sprintf(filenamez,"%s(%s).bin",title,timein);
Download(url,OpenFile(filenamez));}
keyboard=0;
}
if(keyboard==6){
PLSearch(url);
keyboard=0;
}
@ -850,30 +1108,23 @@ keyboard=0;
if(keyboard==1){
Search(url);
}
if(keyboard==3){
if(keyboard==4){
Playlist(url);
}
if(keyboard==2){
if(addtopltxt==1 && pltxtselected==1){
WriteFile2PL(pltxt,"vi",url,"NOTITLE");
}else{
char filenamez[530];
char timein[20];
time_t now = time(0);
strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now));
char title[300];
char idTool2[500];
sprintf(idTool2,"https://stark-shelf-08981.herokuapp.com/Grabber/info/%s",url);
if(Download(idTool2,Temp())){
FILE *f = fopen(Temp(),"r");
fgets(title,300,f);
fclose(f);
DeleteTemp();
PatchString(title);
}else{
sprintf(title,"NOTITLE");
}
sprintf(filenamez,"%s(%s)",title,timein);
@ -881,15 +1132,41 @@ keyboard=0;
sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",url);
Download(idTool,OpenVideoFile(filenamez));
}keyboard=0;
}
if(keyboard==4){
LoadQuery(url);
if(keyboard==3){
if(addtopltxt==1 && pltxtselected==1){
WriteFile2PL(pltxt,"dl",url,"NOTITLE(%s).bin");
}else{
char filenamez[530];
char timein[20];
time_t now = time(0);
strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now));
char title[300];
sprintf(title,"NOTITLE");
sprintf(filenamez,"%s(%s).bin",title,timein);
Download(url,OpenFile(filenamez));}
keyboard=0;
}
if(keyboard==5){
pltxtselected = 1;
snprintf(pltxt,40,"%s.txt",url);
CreatePL(pltxt);
keyboard=0;
}
keyboard=0;
}else{
if (GoingBack() == 0) {
snprintf(url, 40, "%s%c", url, Place());
snprintf(url, 2048, "%s%c", url, Place());
}
else {
@ -903,7 +1180,7 @@ keyboard=0;
if (key & WPAD_BUTTON_A) {
if (GoingBack() == 0) {
snprintf(url, 40, "%s%c", url, Place());
snprintf(url, 2048, "%s%c", url, Place());
}
else {
@ -929,15 +1206,18 @@ keyboard=0;
int netclose_callback (void *clientp, curl_socket_t item) {
return net_close(item);
}
int Download(char* url, char* file) {
int Download2(char* url, char* file,int plid) {
CURL* curl;
curl = curl_easy_init();
int ret=1;
dlf dr;
dr.fp =fopen(file,"wb");
sprintf(dr.fnam,"%s",file);
dr.fileid=0;
sprintf(dr.fnam2,"%s",FileNameParse(file));
dr.fileid=0;
dr.fileindex = plid;
curl_easy_setopt(curl,CURLOPT_URL,url);
curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
@ -965,6 +1245,7 @@ curl_easy_cleanup(curl);
return ret;
}
void Search(char* search) {
char output2[600];
char* output = ConvertString(search);
@ -974,6 +1255,7 @@ void Search(char* search) {
if(Download(output2,Temp())){
FILE *f = fopen(Temp(),"r");
char download[1001];
listtype=1;
videos=-1;
while(fgets(download,1001,f)!=NULL && videos<499){
@ -991,6 +1273,7 @@ void Search(char* search) {
}
}
void PLSearch(char* search) {
listtype=1;
char output2[600];
char* output = ConvertString(search);
@ -1017,12 +1300,13 @@ void PLSearch(char* search) {
}
void PlaylistEx(char* search,char* nm) {
void PlaylistEx(char* search,char* nm,int* ptrs) {
char output2[600];
char timeins[20];
time_t nows = time(0);
strftime(timeins, sizeof(timeins), "%Y%m%d_%H%M%S", localtime(&nows));
char* ssname[300];
char ssname[300];
sprintf(ssname,"%s(%s)",nm,timeins);
OpenPlaylistFile(ssname);
char* output = ConvertString(search);
@ -1047,9 +1331,9 @@ char timeins[20];
char idTool[500];
sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",id);
Download(idTool,OpenPlaylistVideoFile(ssname,filename));
Download2(idTool,OpenPlaylistVideoFile(ssname,filename),*ptrs);
(*ptrs)++;
}
DeleteTemp();
}
@ -1112,7 +1396,7 @@ void keyPress_cb( char sym) {
}*/
int main() {
char options[6][50]={"Input Search Term","Input Youtube URL","Input Playlist URL","Input Playlist Text File","Playlist As Search","Channel"};
char options[9][50]={"Input Search Term","Input Youtube URL","Input File URL","Input Playlist URL","Create PLTXT File","Playlist As Search","Channel","Add To PL","Google Images"};
char optionsforChannel[4][50]={"Channel New Videos","ChannelUser New Videos","Channel Videos","ChannelUser Videos"};
char listingmode[2][9]={"List","Download"};
WPAD_Init();
@ -1181,7 +1465,7 @@ FileSystemDrivers();
CreateFolders();
net_init();
KEYBOARD_Init(keyPress_cb);
// Initialise the video system
@ -1194,6 +1478,7 @@ LoadHistory();
//early testing
//sprintf(url,"Demi Lovato");
char pltxtadds[2][50] ={"Add To PLTXT: OFF","Add To PLTXT: ON"};
pos=-1;
//keyboard=1;
while (running) {
@ -1238,12 +1523,15 @@ pos=-1;
//draw white rectangle
if(channelsetting<0){
GRRLIB_Rectangle(150,224,340,32, GetColor(DOWNLOAD_TEXTBOX_BACKGROUND),1);
GRRLIB_Rectangle(0,223,640,34, GetColor(DOWNLOAD_TEXTBOX_FOREGROUND),0);
GRRLIB_Rectangle(0,224,640,32, GetColor(DOWNLOAD_TEXTBOX_BACKGROUND),1);
}
//draw keyboard
if(keyboard>0){
WPAD_KEYBOARD(ke);
GRRLIB_PrintfTTF(12,223-30, myFont,pltxtadds[addtopltxt], 24,GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR));
if(channelsetting>-1){
@ -1334,7 +1622,7 @@ pos=-1;
void Channel(char* channel,int isuser,int downlo){
char output2[600];
int idn =1;
if(isuser){
sprintf(output2,"https://stark-shelf-08981.herokuapp.com/Grabber/User/%s",channel);
}else{
@ -1346,7 +1634,7 @@ char output2[600];
if(Download(output2,Temp())){
FILE *f = fopen(Temp(),"r");
char downloa[1001];
if(!downlo) videos=-1;
if(!downlo) {videos=-1;listtype=1;}
while(fgets(downloa,1001,f)!=NULL && (videos<499 || downlo==1)){
if(downlo){
char id[13];
@ -1361,8 +1649,8 @@ if(downlo){
char idTool[500];
sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",id);
Download(idTool,OpenVideoFile(filename));
Download2(idTool,OpenVideoFile(filename),idn);
idn++;
}else{
videos++;
sprintf(videoitems[videos],"%s",downloa);
@ -1380,6 +1668,7 @@ if(downlo){
void ChannelNew(char* channel,int isuser,int downlo,char* date){
int idn=1;
char output2[600];
if(isuser){
@ -1393,7 +1682,7 @@ void ChannelNew(char* channel,int isuser,int downlo,char* date){
if(Download(output2,Temp())){
FILE *f = fopen(Temp(),"r");
char downloa[1001];
if(!downlo) videos=-1;
if(!downlo){ videos=-1; listtype=1;}
while(fgets(downloa,1001,f)!=NULL && (videos<499 || downlo==1)){
if(downlo){
@ -1409,8 +1698,8 @@ if(downlo){
char idTool[500];
sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",id);
Download(idTool,OpenVideoFile(filename));
Download2(idTool,OpenVideoFile(filename),idn);
idn++;
}else{
videos++;
sprintf(videoitems[videos],"%s",downloa);
@ -1423,3 +1712,104 @@ if(downlo){
}
void PLTXTSearch(){
videos=-1;
DIR *pdir;
struct dirent *pent;
pdir=opendir("/TYTD/PLTXT/");
listtype=2;
if (!pdir){
exit(0);
}
while ((pent=readdir(pdir))!=NULL) {
if(strcmp(".", pent->d_name) == 0 || strcmp("..", pent->d_name) == 0)
continue;
if(pent->d_type == DT_REG){
videos++;
sprintf(videoitems[videos],"%s",pent->d_name);
}
}
closedir(pdir);
//
//
}
void DL_IMAGES(char* name){
char url2222[3000];
sprintf(url2222,"https://www.google.com/search?tbm=isch&q=%s",SString(name));
Download(url2222,Temp());
FILE *f = fopen(Temp(),"r");
fseek(f,SEEK_END,0);
long lengths=ftell(f);
char* array = malloc(sizeof(char) * (lengths + 3));
array[lengths+1];
rewind(f);
fread(array,sizeof(char),lengths,f);
char url2223[2048];
int chartype = 0; //0 is no 1=s 2 = r 3 = c 4 = = 5 = "
int strp = 0;
int filesr=1;
for(size_t ie=0;ie<strlen(array);ie++){
if(chartype==0){
if(array[ie]=='s'){
chartype=1;
continue;
}
}
if(chartype==1){
if(array[ie]=='r'){
chartype=2;
continue;
}else{
chartype=0;
}
}
if(chartype==2){
if(array[ie]=='c'){
chartype=3;
continue;
}else{
chartype=0;
}
}
if(chartype==3){
if(array[ie]=='='){
chartype=4;
continue;
}else{
chartype=0;
}
}
if(chartype==4){
if(array[ie]=='"'){
chartype=5;
strp=0;
continue;
}else{
chartype=0;
}
}
if(chartype==5){
if(array[ie]!='"'){
url2223[strp] = array[ie];
strp++;
continue;
}else{
url2223[strp] = '\0';
char fnameser[80];
sprintf(fnameser,"%s(%%s).jpg",name);
Download2(url2223,OpenFile(fnameser),filesr);
strp=0;
filesr++;
chartype=0;
}
}
}
}

View File

@ -1,6 +1,21 @@
#include "settings.h"
int irmode=0;
char* FileNameParse(char* path){
char *yt = malloc(sizeof(char)*530);
size_t len = strlen(path);
size_t pos=0;
for(size_t i = len-1;path[i] != '/';i--){
pos = i;
}
for(size_t i = pos;i<=len;i++){
size_t ind = i - pos;
yt[ind] = path[i];
}
return yt;
}
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;
@ -30,9 +45,29 @@ FILE* HistoryAppend(){
FILE* PlaylistTXT(char* fil){
char file2[500];
sprintf(file2,"/TYTD/PLTXT/%s.txt",fil);
sprintf(file2,"/TYTD/PLTXT/%s",fil);
return fopen(file2,"r");
}
void CreatePL(char* fil){
char file2[500];
sprintf(file2,"/TYTD/PLTXT/%s",fil);
FILE *f =fopen(file2,"w");
fclose(f);
}
void WriteFile2PL(char* fil,char* type,char* url,char* filename){
char file2[500];
sprintf(file2,"/TYTD/PLTXT/%s",fil);
FILE *f =fopen(file2,"a");
fseek(f,0,SEEK_END);
if(ftell(f) == 0L){
fprintf(f,"%s %s %s",type,url,filename);
}else{
fprintf(f,"\n%s %s %s",type,url,filename);
}
fclose(f);
}
int FileSystemDrivers(){
fatInitDefault();
USBStorage_Initialize();

View File

@ -1,18 +1,20 @@
#ifndef SETTINGS_H
#define SETTINGS_H
#include <gccore.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fat.h>
#include <unistd.h>
#include <sys/stat.h>
#include <ogc/usbstorage.h>
#include <stdio.h>
#include <stdlib.h>
#include <gccore.h>
#include <wiiuse/wpad.h>
#include <string.h>
#include <time.h>
#include <curl/curl.h>
#include <grrlib.h>
#include "FreeMonoBold_ttf.h"
@ -20,9 +22,11 @@
typedef struct dlf{
FILE* fp;
char fnam[1000];
char fnam2[500];
int fileid;
int fileindex;
}dlf;
char* FileNameParse(char* path);
void DLFhandler(dlf* dl,size_t real);
void OpenPlaylistFile(char* playlist);
char* OpenFile(char* fname);
@ -32,6 +36,8 @@ FILE* HistoryRead();
FILE* HistoryAppend();
int UsingIRFeatures();
int FileSystemDrivers();
void WriteFile2PL(char* fil,char* type,char* url,char* filename);
void CreatePL(char* fil);
char* OpenVideoFile(char* filename);
char* ThumbnailFileName(char* filename);
int ThumbnailExists(char* id);