#include "colors.h" #include 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) { 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; char videoitems[500][1001]; int keyboard = 0; 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[2048]; void PlaylistEx(char*,char*,int*); void Playlist(char* pl){ int i=1; PlaylistEx(pl,"Playlist",&i); } void Search(char*); void PLSearch(char*); void LoadHistory(){ FILE *f =HistoryRead(); char download[40]; if (!f)return; while(fgets(download,40,f)!=NULL && historyobjs<2000){ for(int i = 0;i<41;i++){ if(download[i]=='\n'){ download[i]='\0'; break; } } sprintf(history[historyobjs],"%s",download); historyobjs++; } fclose(f); } void AddHistory(){ if(historyobjs<2000){ sprintf( history[historyobjs],"%s",url); char urls[42]; sprintf(urls,"%s\n",url); FILE *f =HistoryAppend(); fputs(urls,f); fclose(f); historyobjs++; } } #define KEYBOARD_MOVELEFT 180 #define KEYBOARD_MOVERIGHT 0 #define KEYBOARD_MOVEUP 90 #define KEYBOARD_MOVEDOWN 270 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); 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]=='@' || 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* 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]); } } return code; } void PatchString(char*src) { for(int i = 0;i<(int)strlen(src);i++){ if(src[i]=='\n')src[i]=' '; if(src[i]=='\r')src[i]=' '; 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) { 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); GRRLIB_FillScreen(GetColor(DOWNLOAD_BACKGROUND)); char filenamersr[1008]; 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, 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 < 5; 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++) { for (int x = 0; x < 11; x++) { if(GRRLIB_PtInRect(posx + (x*20),posy + (y * 20),20,20,irs.x,irs.y)){ charx=x; chary=y; } } } } //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--;}else{charx=10;} break; case KEYBOARD_MOVERIGHT: if (charx < 10){charx++;}else{charx=0;} break; case KEYBOARD_MOVEUP: if (chary > 0){chary--;}else{chary=4;} break; case KEYBOARD_MOVEDOWN: 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) { 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); snprintf(title2,sizeof(title2),"%s",title); snprintf(author2,sizeof(author2),"%s",author); PatchString(title2); PatchString(author2); int o=(i == 2); 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)); if(willtry){ if(!ThumbnailExists(id)){ if(!Download(ThumbnailURL(id),ThumbnailFileName(id))){ unlink(ThumbnailFileName(id)); } } if(ThumbnailExists(id)){ GRRLIB_texImg *tex = GRRLIB_LoadTextureFromFile (ThumbnailFileName(id)); 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 ------------------------------------------------------------------------- */ } 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(); } if (key & WPAD_BUTTON_UP) { if(pos>-2)pos--; } if (key & WPAD_BUTTON_LEFT) { if(pos==-1){ if(historyobj>0){ historyobj--; sprintf(url,"%s",history[historyobj]); }else{ if(historyobjs>0){ historyobj=0; sprintf(url,"%s",history[historyobj]); } } } } if (key & WPAD_BUTTON_RIGHT) { if(pos==-1){ if(historyobj0){ pos=0; }else{ pos=-1; } } if (key & WPAD_BUTTON_DOWN) { if(pos-1){ if(GRRLIB_PtInRect(0,0,31,480,ir.x,ir.y)){ GRRLIB_Rectangle(0,0,31,480,GetColor(DOWNLOAD_SELECTOR),1); } if(GRRLIB_PtInRect(609,0,31,480,ir.x,ir.y)){ GRRLIB_Rectangle(609,0,31,480,GetColor(DOWNLOAD_SELECTOR),1); } }else if(GRRLIB_PtInRect(0,416,640,64,ir.x,ir.y)){ GRRLIB_Rectangle(0,416,640,64,GetColor(DOWNLOAD_SELECTOR),1); } } if (UsingIRFeatures() && (key & WPAD_BUTTON_A)){ if(pos>-1 && listtype !=2){ int clickid=0; int clickedtype=-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(0,0,31,480,ir.x,ir.y)){ clickedtype=1; } if(GRRLIB_PtInRect(609,0,31,480,ir.x,ir.y)){ clickedtype=2; } if(GRRLIB_PtInRect(32,32,576,90,ir.x,ir.y)){ clickid=-2; clickedtype=0; } if(GRRLIB_PtInRect(32,32+90,576,90,ir.x,ir.y)){ clickid=-1; clickedtype=0; } if(GRRLIB_PtInRect(32,32+(90*2),576,90,ir.x,ir.y)){ clickid=0; clickedtype=0; } if(GRRLIB_PtInRect(32,32+(90*3),576,90,ir.x,ir.y)){ clickid=1; clickedtype=0; } if(GRRLIB_PtInRect(32,32+(90*4),576,90,ir.x,ir.y)){ clickid=2; clickedtype=0; } if(clickedtype==0){ if ((pos + clickid) >= 0 && (pos + clickid) < videos) { char id[13]; char title[500]; sscanf(videoitems[pos + clickid], "%13s %500s", id, title); PatchString(title); char filename[530]; char timein[20]; time_t now = time(0); strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now)); sprintf(filename,"%s(%s)",title,timein); char idTool[500]; sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",id); Download(idTool,OpenVideoFile(filename)); } }else if(clickedtype==1){ if(pos-5>=0){ pos-=5; }else{ pos=0; } }else if(clickedtype==2){ if(pos+5-1){ if(listtype==1){ //download char id[13]; char title[500]; sscanf(videoitems[pos], "%13s %500s", id, title); PatchString(title); char filename[530]; char timein[20]; time_t now = time(0); strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now)); sprintf(filename,"%s(%s)",title,timein); 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; } } } if(UsingIRFeatures() && (key & WPAD_BUTTON_1)){ 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) { sscanf(videoitems[pos + clickid], "%13s", id); }else{ sprintf(id,"%s",url); } char* idTool = ThumbnailURL(id); char* filename1= ThumbnailFileName(id); if(!ThumbnailExists(id)){ if(!Download(idTool,filename1)){ unlink(filename1); } } if(ThumbnailExists(id)){ GRRLIB_texImg *tex = GRRLIB_LoadTextureFromFile (filename1); while(1){ WPAD_ScanPads(); // Scan the Wii Remotes u32 ke=WPAD_ButtonsDown(0); if(ke & WPAD_BUTTON_B) break; GRRLIB_FillScreen(GetColor(DOWNLOAD_BACKGROUND)); GRRLIB_DrawImg (32, 24, tex, 0, 1.2, 1.2, RGBA(255,255,255,255)); GRRLIB_Render(); } GRRLIB_FreeTexture (tex); } } }else{ if(key & WPAD_BUTTON_1){ char id[13]; if (pos >= 0 && pos < videos) { sscanf(videoitems[pos], "%13s", id); }else{ sprintf(id,"%s",url); } char* idTool = ThumbnailURL(id); char* filename1= ThumbnailFileName(id); if(!ThumbnailExists(id)){ if(!Download(idTool,filename1)){ unlink(filename1); } } if(ThumbnailExists(id)){ GRRLIB_texImg *tex = GRRLIB_LoadTextureFromFile (filename1); while(1){ WPAD_ScanPads(); // Scan the Wii Remotes u32 ke=WPAD_ButtonsDown(0); if(ke & WPAD_BUTTON_B) break; GRRLIB_FillScreen(GetColor(DOWNLOAD_BACKGROUND)); GRRLIB_DrawImg (32, 24, tex, 0, 1.2, 1.2, RGBA(255,255,255,255)); GRRLIB_Render(); } 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){ char type[3]; char url2[500]; char data[256]; if(fscanf(f," %3s %500s %256s",type,url2,data)==EOF)break; PatchString(data); if (strcmp("tn",type)==0){ //video on url2 char* idTool = ThumbnailURL(url2); char* filename1= ThumbnailFileName(url2); if(!ThumbnailExists(url2)){ if(!Download(idTool,filename1)){ unlink(filename1); } } }else if (strcmp("vi",type)==0){ //video on url2 char filenamez[530]; char timein[20]; time_t now = time(0); strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now)); sprintf(filenamez,"%s(%s)",data,timein); char idTool[500]; sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",url2); Download2(idTool,OpenVideoFile(filenamez),filesr); }else if(strcmp("pl",type)==0){ //playlist on url2 PlaylistEx(url2,data,&filesr); }else if(strcmp("dl",type)==0){ //playlist on url2 Download2(url2,OpenFile(data),filesr); } filesr++; } } fclose(f); } 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(); } if ((key & WPAD_BUTTON_B )&& channelsetting==-1) { Caps(); } if(channelsetting==-1){ if (key & WPAD_BUTTON_1) { //change keyboard if keyboard<4 instead of 3 LoadQuery Enabled if(keyboard<9){ keyboard++; }else{ keyboard=1; } } }else{ if (key & WPAD_BUTTON_1) { if(channelsetting<3){ channelsetting++; }else{ channelsetting=0; } } } if(channelsetting==-1){ if (key & WPAD_BUTTON_PLUS) { //apply plus: if(mustadd==1){ AddHistory(); mustadd=0; //keyboard=0; } if(keyboard==1){ Search(url); keyboard=0; } 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); 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); sprintf(title,"NOTITLE"); sprintf(filenamez,"%s(%s)",title,timein); char idTool[500]; sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",url); Download(idTool,OpenVideoFile(filenamez)); } keyboard=0; } if(keyboard==5){ //LoadQuery(url); pltxtselected = 1; snprintf(pltxt,40,"%s.txt",url); CreatePL(pltxt); keyboard=0; } if(keyboard==7){ channelsetting=0; return; } 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; } } }else{ if (key & WPAD_BUTTON_PLUS) { if(channelsetting==0){ //-1 not enabled 0 for channel new 1 for user new 2 for channel 3 for user char dates[12]; sprintf(dates,"%i-%i-%i",yearnew,monthnew,daynew); ChannelNew(url,0,downloadnotlist,dates); }else if(channelsetting==1){ char dates[12]; sprintf(dates,"%i-%i-%i",yearnew,monthnew,daynew); ChannelNew(url,1,downloadnotlist,dates); }else if(channelsetting==2){ //-1 not enabled 0 for channel new 1 for user new 2 for channel 3 for user Channel(url,0,downloadnotlist); }else if(channelsetting==3){ Channel(url,1,downloadnotlist); } keyboard =0; channelsetting=-1; } } if (key & WPAD_BUTTON_MINUS) { //cancel keyboard=0; channelsetting=-1; } if(channelsetting==-1){ if (key & WPAD_BUTTON_LEFT) { KeyMove(KEYBOARD_MOVELEFT); } if (key & WPAD_BUTTON_RIGHT) { KeyMove(KEYBOARD_MOVERIGHT); } if (key & WPAD_BUTTON_UP) { KeyMove(KEYBOARD_MOVEUP); } if (key & WPAD_BUTTON_DOWN) { KeyMove(KEYBOARD_MOVEDOWN); }}else if(channelsetting==0 || channelsetting==1){ if (key & WPAD_BUTTON_LEFT) { if(coldate>0){ coldate--; }else{ coldate=2; } } if (key & WPAD_BUTTON_RIGHT) { if(coldate<2){ coldate++; }else{ coldate=0; } } if (key & WPAD_BUTTON_UP) { if(coldate==0){ //month if(monthnew < monthcap){ monthnew++; }else{ monthnew=1; } } if(coldate==1){ //day if(daynew < daycap){ daynew++; }else{ daynew=1; } } if(coldate==2){ yearnew++; } } if (key & WPAD_BUTTON_DOWN) { if(coldate==0){ //month if(monthnew > 1){ monthnew--; }else{ monthnew=monthcap; } } if(coldate==1){ //day if(daynew > 1){ daynew--; }else{ daynew=daycap; } } if(coldate==2){ yearnew--; } } } if(channelsetting==-1){ if(UsingIRFeatures()){ SetKeyFromCord(ir,230,224+126); if(key & WPAD_BUTTON_A){ if(GRRLIB_PtInRect(150+50,224+35,340-100,32,ir.x,ir.y)){ if(mustadd==1){ AddHistory(); mustadd=0; } if(keyboard==1){ Search(url); } 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]; sprintf(title,"NOTITLE"); sprintf(filenamez,"%s(%s)",title,timein); char idTool[500]; sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",url); Download(idTool,OpenVideoFile(filenamez)); }keyboard=0; } 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, 2048, "%s%c", url, Place()); } else { if (strlen(url) > 0) { url[strlen(url) - 1] = '\0'; } } mustadd=1; }} }else{ if (key & WPAD_BUTTON_A) { if (GoingBack() == 0) { snprintf(url, 2048, "%s%c", url, Place()); } else { if (strlen(url) > 0) { url[strlen(url) - 1] = '\0'; } } mustadd=1; } } }else{ if(key & WPAD_BUTTON_A){ if(downloadnotlist==0){ downloadnotlist=1; }else{ downloadnotlist=0; } } } } int netclose_callback (void *clientp, curl_socket_t item) { return net_close(item); } 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); 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); curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, netclose_callback); /* disable progress meter, set to 0L to enable and disable debug output */ curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); 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_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(dr.fp); fclose(dr.fp); if(bytes==0 && dr.fileid==0){ unlink(file); ret=0; } curl_easy_cleanup(curl); return ret; } void Search(char* search) { char output2[600]; char* output = ConvertString(search); if (output) { sprintf(output2,"https://stark-shelf-08981.herokuapp.com/Grabber/searchinfo/%s",output); if(Download(output2,Temp())){ FILE *f = fopen(Temp(),"r"); char download[1001]; listtype=1; videos=-1; while(fgets(download,1001,f)!=NULL && videos<499){ videos++; sprintf(videoitems[videos],"%s",download); } fclose(f); DeleteTemp(); } } } void PLSearch(char* search) { listtype=1; char output2[600]; char* output = ConvertString(search); if (output) { sprintf(output2,"https://stark-shelf-08981.herokuapp.com/Grabber/playlistinfo/%s",output); if(Download(output2,Temp())){ FILE *f = fopen(Temp(),"r"); char download[1001]; videos=-1; while(fgets(download,1001,f)!=NULL && videos<499){ videos++; sprintf(videoitems[videos],"%s",download); } fclose(f); DeleteTemp(); } } } 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]; sprintf(ssname,"%s(%s)",nm,timeins); OpenPlaylistFile(ssname); char* output = ConvertString(search); if (output) { sprintf(output2,"https://stark-shelf-08981.herokuapp.com/Grabber/playlistinfo/%s",output); free(output); if(Download(output2,Temp())){ FILE *f = fopen(Temp(),"r"); char download[1001]; while(fgets(download,1001,f)!=NULL ){ char id[13]; char title[500]; sscanf(download, " %13s %500s", id, title); char filename[530]; char timein[20]; time_t now = time(0); strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now)); PatchString(title); sprintf(filename,"%s(%s)",title,timein); char idTool[500]; sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",id); Download2(idTool,OpenPlaylistVideoFile(ssname,filename),*ptrs); (*ptrs)++; } DeleteTemp(); } } } int running = 1; void PressKey(u32 key){ if (keyboard>0) { WPAD_KEYBOARD(key); }else{ WPAD_ONMENU(key); } }/* void keyPress_cb( char sym) { if (keyboard>0 && ((sym >= 'a' && sym <= 'z') || (sym>='A' && sym <='Z' ) || (sym>='0' && sym<='9') || sym=='_' || sym==' ' || sym=='+' || sym=='(' || sym==')' || sym=='[' || sym==']'||sym==','||sym=='-'||sym==':'||sym==';')) snprintf(url, 40, "%s%c", url, sym); if (sym == 13) {if(keyboard==0){PressKey(WPAD_BUTTON_A);}else{PressKey(WPAD_BUTTON_PLUS);}} if (sym & KS_Up){ if(keyboard==0){ PressKey(WPAD_BUTTON_UP); } } if (sym & KS_Down){ if(keyboard==0){ PressKey(WPAD_BUTTON_DOWN); } } if (sym & KS_F1 || sym & KS_f1){ if(keyboard==0){ if(pos>-2){ pos=-2; }else{ pos=-3; } } } if (sym & KS_F2 || sym & KS_f2){ if(keyboard>0){ PressKey(WPAD_BUTTON_1); } } if (sym & KS_F3 || sym & KS_f3){ if(keyboard==0){ PressKey(WPAD_BUTTON_B); }else{ PressKey(WPAD_BUTTON_MINUS); } } if ( sym & 0x1b) running=0; }*/ int main() { 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(); GRRLIB_Init(); myFont = GRRLIB_LoadTTF(FreeMonoBold_ttf, FreeMonoBold_ttf_size); WPAD_SetVRes(0,640,480); WPAD_SetDataFormat(WPAD_CHAN_0,WPAD_FMT_BTNS_ACC_IR); InitColor(0); int csch=0; while(1){ WPAD_ScanPads(); // Scan the Wii Remotes GRRLIB_FillScreen(GetColor(DOWNLOAD_BACKGROUND)); if(UsingIRFeatures()){ WPAD_IR(0,&ir); GRRLIB_Rectangle(ir.x,ir.y,4,4,GetColor(DOWNLOAD_CURSOR),1); } u32 ke=WPAD_ButtonsDown(0); if (ke & WPAD_BUTTON_A) { break; } if (ke & WPAD_BUTTON_1) { csch = AddScheme(csch); InitColor(csch); } if (ke & WPAD_BUTTON_2) { SwitchIR(); } if(ke & WPAD_BUTTON_B){ if(willtry){ willtry=0; }else{ willtry=1; } } GRRLIB_PrintfTTF(50, 50, myFont,"Press (A) To Enter TYTD", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); char listimages[40]; if(willtry){ sprintf(listimages,"Download thumbnails is on Press (B) to change"); }else{ sprintf(listimages,"Download thumbnails is off press (B) to change"); } GRRLIB_PrintfTTF(50, 50+30, myFont,listimages , 18, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); char sensor[40]; if(UsingIRFeatures()){ sprintf(sensor,"IR is on press (2) to change anytime"); }else{ sprintf(sensor,"IR is off press (2) to change anytime"); } GRRLIB_PrintfTTF(50, 50+60, myFont,sensor, 18, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); char scl[40]; sprintf(scl,"press (1) for colorscheme, colorscheme=%i",csch); GRRLIB_PrintfTTF(50, 50+90, myFont,scl, 18, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); GRRLIB_Render(); } FileSystemDrivers(); CreateFolders(); net_init(); KEYBOARD_Init(keyPress_cb); // Initialise the video system // This function initialises the attached controllers LoadHistory(); //printf("\n\n\n\nwhats on your mind\n\n(-) Playlist URL (+) URL (2) Search"); //url[0]='\0'; //early testing //sprintf(url,"Demi Lovato"); char pltxtadds[2][50] ={"Add To PLTXT: OFF","Add To PLTXT: ON"}; pos=-1; //keyboard=1; while (running) { WPAD_ScanPads(); // Scan the Wii Remotes GRRLIB_FillScreen(GetColor(DOWNLOAD_BACKGROUND)); u32 ke=WPAD_ButtonsDown(0); if (ke & WPAD_BUTTON_HOME) { break; } if(pos>-1){ WPAD_ONMENU(ke); DrawList(); }else if(pos==-2){ WPAD_ONMENU(ke); GRRLIB_PrintfTTF(32, 32, myFont,"Controls", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 64, myFont," (DPAD) MOVE (A) Place Letter", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 64+32, myFont,"if Letter is '<' then backspace", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 128, myFont,"(-) Cancel (+) Accept", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 128+32, myFont,"(B) Caps (1) Change Method", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 256, myFont,"
(DPAD UP/DOWN) MOVE", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 256+32, myFont,"(A) Enable KB/Download", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 256+64, myFont,"UP ON LIST BRINGS YOU TO ", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 256+64+32, myFont,"SEARCH SCREEN (B) Advance To Top ", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 256+64+64, myFont,"THIS SCREEN/FIRST ELEMENT (B) Search Screen", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text }else if(pos==-3){ WPAD_ONMENU(ke); GRRLIB_PrintfTTF(32, 32, myFont,"Controls", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 256, myFont,"
UP/DOWN MOVE", 24,GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 256+32, myFont,"ENTER Enable KB/Download", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 256+64, myFont,"UP ON LIST BRINGS YOU TO ", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 256+64+32, myFont,"SEARCH SCREEN Advance To Top ", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text GRRLIB_PrintfTTF(32, 256+64+64, myFont,"THIS SCREEN/FIRST ELEMENT Search Screen", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //white text }else{ //draw white rectangle if(channelsetting<0){ 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){ GRRLIB_PrintfTTF(128+90+90, 227+30, myFont,listingmode[downloadnotlist], 24,GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); int offsetforstring2=(int)(GRRLIB_WidthTTF (myFont, optionsforChannel[channelsetting], 24))/2; int startx2=320-offsetforstring2; GRRLIB_PrintfTTF(startx2, 96, myFont,optionsforChannel[channelsetting], 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //black text if(channelsetting<2){ //draw date char mon[4]; char dat[4]; char yer[5]; sprintf(mon,"%i-",monthnew); sprintf(dat,"%i-",daynew); snprintf(yer,5,"%i",yearnew); if(coldate==0){ GRRLIB_PrintfTTF(128, 227, myFont,mon, 24,GetColor(DOWNLOAD_TEXTBOX_BACKGROUND)); }else{ GRRLIB_PrintfTTF(128, 227, myFont,mon, 24,GetColor(DOWNLOAD_TEXTBOX_FOREGROUND)); } if(coldate==1){ GRRLIB_PrintfTTF(128+90, 227, myFont,dat, 24,GetColor(DOWNLOAD_TEXTBOX_BACKGROUND)); }else{ GRRLIB_PrintfTTF(128+90, 227, myFont,dat, 24,GetColor(DOWNLOAD_TEXTBOX_FOREGROUND)); } if(coldate==2){ GRRLIB_PrintfTTF(128+90+90, 227, myFont,yer, 24,GetColor(DOWNLOAD_TEXTBOX_BACKGROUND)); }else{ GRRLIB_PrintfTTF(128+90+90, 227, myFont,yer, 24,GetColor(DOWNLOAD_TEXTBOX_FOREGROUND)); } } }else{ DrawKeyBoard(230,224+126); if(UsingIRFeatures()){ GRRLIB_Rectangle(150+50,224+35,340-100,32, GetColor(DOWNLOAD_SELECTOR),1); int offsetforstring=(int)(GRRLIB_WidthTTF (myFont, "Submit", 24))/2; int startx=320-offsetforstring; GRRLIB_PrintfTTF(startx, 227+35, myFont,"Submit", 24, GetColor(DOWNLOAD_FOREGROUND_SELECTOR)); //blue text } }}else{ GRRLIB_PrintfTTF(32, 400, myFont,"to access help Press Up", 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //black text WPAD_ONMENU(ke); } if(channelsetting<0){ //center text in white rectangle AKA textbox int offsetforstring=(int)(GRRLIB_WidthTTF (myFont, url, 24))/2; int startx=320-offsetforstring; GRRLIB_PrintfTTF(startx, 227, myFont,url, 24,GetColor(DOWNLOAD_TEXTBOX_FOREGROUND)); //black text //draw Option if(keyboard>0){ int offsetforstring2=(int)(GRRLIB_WidthTTF (myFont, options[keyboard-1], 24))/2; int startx2=320-offsetforstring2; GRRLIB_PrintfTTF(startx2, 96, myFont,options[keyboard-1], 24, GetColor(DOWNLOAD_FOREGROUND_NO_SELECTOR)); //black text } }} if(UsingIRFeatures()){ WPAD_IR(0,&ir); GRRLIB_Rectangle(ir.x,ir.y,4,4,GetColor(DOWNLOAD_CURSOR),1); } GRRLIB_Render(); } GRRLIB_FreeTTF(myFont); GRRLIB_Exit(); exit(0); return 0; } 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{ sprintf(output2,"https://stark-shelf-08981.herokuapp.com/Grabber/Channel/%s",channel); } if(Download(output2,Temp())){ FILE *f = fopen(Temp(),"r"); char downloa[1001]; if(!downlo) {videos=-1;listtype=1;} while(fgets(downloa,1001,f)!=NULL && (videos<499 || downlo==1)){ if(downlo){ char id[13]; char title[500]; sscanf(downloa, " %13s %500s", id, title); char filename[530]; char timein[20]; time_t now = time(0); strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now)); PatchString(title); sprintf(filename,"%s(%s)",title,timein); char idTool[500]; sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",id); Download2(idTool,OpenVideoFile(filename),idn); idn++; }else{ videos++; sprintf(videoitems[videos],"%s",downloa); } } DeleteTemp(); } } void ChannelNew(char* channel,int isuser,int downlo,char* date){ int idn=1; char output2[600]; if(isuser){ sprintf(output2,"https://stark-shelf-08981.herokuapp.com/Grabber/UserNew/%s/%s",date,channel); }else{ sprintf(output2,"https://stark-shelf-08981.herokuapp.com/Grabber/ChannelNew/%s/%s",date,channel); } if(Download(output2,Temp())){ FILE *f = fopen(Temp(),"r"); char downloa[1001]; if(!downlo){ videos=-1; listtype=1;} while(fgets(downloa,1001,f)!=NULL && (videos<499 || downlo==1)){ if(downlo){ char id[13]; char title[500]; sscanf(downloa, " %13s %500s", id, title); char filename[530]; char timein[20]; time_t now = time(0); strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now)); PatchString(title); sprintf(filename,"%s(%s)",title,timein); char idTool[500]; sprintf(idTool,"https://stark-shelf-08981.herokuapp.com/Grabber/Video/%s",id); Download2(idTool,OpenVideoFile(filename),idn); idn++; }else{ videos++; sprintf(videoitems[videos],"%s",downloa); } } DeleteTemp(); } } 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