Skip to content

Commit

Permalink
v1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
khalidwaleed0 committed Apr 6, 2020
1 parent b57aacf commit 745cd72
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 10 deletions.
1 change: 1 addition & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/AnimeNinja/
Binary file modified bin/AnimeNinja/downloader.class
Binary file not shown.
Binary file modified bin/AnimeNinja/gui$12.class
Binary file not shown.
Binary file modified bin/AnimeNinja/gui$13.class
Binary file not shown.
Binary file modified bin/AnimeNinja/gui$loading.class
Binary file not shown.
Binary file modified bin/AnimeNinja/gui.class
Binary file not shown.
Binary file modified bin/AnimeNinja/scraper.class
Binary file not shown.
69 changes: 62 additions & 7 deletions src/AnimeNinja/downloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class downloader implements Runnable{
private static HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
protected static ArrayList<String> megaLinks = new ArrayList<String>();
protected static ArrayList<String> driveLinks = new ArrayList<String>();
protected static ArrayList<String> zippyShareLinks = new ArrayList<String>();
private TrayIcon trayIcon;
private static File defaultDir;
@Override
Expand All @@ -42,13 +43,69 @@ public void run()
showTrayIcon();
megaDownloader();
}


private void zippyShareDownloader()
{
try {
Thread.sleep(500);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
if(zippyShareLinks.size() != 0)
{
gui.lblNewLabel_7.setText("Trying zippyshare Link...");
guiRefresh();
driver2.get(zippyShareLinks.get(0));
zippyShareLinks.remove(0);
try {
String epName = driver2.findElement(By.cssSelector(".center font:nth-of-type(3)")).getText().replaceAll("\\[AnimeSanka.com]\\s|\\s\\(.+", "");
String fullSize = driver2.findElement(By.cssSelector(".center font:nth-of-type(5)")).getText();
driver2.get(driver2.findElement(By.cssSelector("#dlbutton")).getAttribute("href"));
gui.lblNewLabel_3.setVisible(false);
gui.lblNewLabel_3.setText(epName);
gui.lblNewLabel_3.setVisible(true);
File tmpDownload = getTempDownloadFile();
double downloadInfo;
while(true)
{
downloadInfo = tmpDownload.length()/(1024*1024);
if (tmpDownload.exists())
{
System.out.println("finding download info");
System.out.println(fullSize);
gui.lblNewLabel_7.setText(String.valueOf(downloadInfo)+" MB of "+fullSize);
gui.lblNewLabel_5.setText("Files left:"+driveLinks.size());
guiRefresh();
}
else
{
gui.lblNewLabel_7.setText("Download Completed");
guiRefresh();
notifier("Download Completed",epName);
break;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}catch(Exception e) {
gui.lblNewLabel_7.setText("Failed to download EP "+(gui.selectedEpisode+1)+" (Old Links)");
guiRefresh();
notifier("Download Failed (Old Links)","EP "+gui.selectedEpisode+1);
}
}
}

private void driveDownloader()
{
String epName = null;
String fullSize = null;
if(driveLinks.size() != 0)
{
gui.lblNewLabel_7.setText("Trying Google Drive Link...");
guiRefresh();
driver2.get(driveLinks.get(0));
driveLinks.remove(0);
try {
Expand All @@ -62,14 +119,10 @@ private void driveDownloader()
gui.lblNewLabel_3.setText(epName);
gui.lblNewLabel_3.setVisible(true);
}catch(Exception e) {
gui.lblNewLabel_7.setText("Failed to download EP "+(gui.selectedEpisode+1)+" (Old Links)");
guiRefresh();
notifier("Download Failed (Old Links)","EP "+gui.selectedEpisode+1);
zippyShareDownloader();
}
}catch(Exception e) {
gui.lblNewLabel_7.setText("Failed to download EP "+(gui.selectedEpisode+1)+" (Old Links)");
guiRefresh();
notifier("Download Failed (Old Links)","EP "+gui.selectedEpisode+1);
zippyShareDownloader();
return;
}
File tmpDownload = getTempDownloadFile();
Expand Down Expand Up @@ -144,6 +197,8 @@ private void megaDownloader()
{
if(megaLinks.size()!=0)
{
gui.lblNewLabel_7.setText("Trying mega.nz Link...");
guiRefresh();
driver2.get(megaLinks.get(0));
megaLinks.remove(0);

Expand Down
13 changes: 11 additions & 2 deletions src/AnimeNinja/gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private void similarSelect() {
public gui() {
setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/appIcon.png")));
setBackground(Color.DARK_GRAY);
setTitle("Anime Ninja V1.1.1");
setTitle("Anime Ninja V1.2");
setResizable(false);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
addWindowListener((WindowListener) new WindowAdapter()
Expand Down Expand Up @@ -358,15 +358,19 @@ public void actionPerformed(ActionEvent e) {
ld4.execute();
Pattern pat1 = Pattern.compile("(https:\\/\\/mega\\S+)");
Pattern pat2 = Pattern.compile("(https:\\/\\/drive\\S+)");
Matcher mat1 = null,mat2=null;
Pattern pat3 = Pattern.compile("(https:\\/\\/www\\d\\S+)");
Matcher mat1 = null,mat2=null,mat3=null;
for(int i=startComboBox.getSelectedIndex()-1 ; i < endComboBox.getSelectedIndex() ; i++)
{
mat1 = pat1.matcher(scraper.episodes.get(i).getAttribute("data-links"));
mat2 = pat2.matcher(scraper.episodes.get(i).getAttribute("data-links"));
mat3 = pat3.matcher(scraper.episodes.get(i).getAttribute("data-links"));
if(mat1.find())
downloader.megaLinks.add(mat1.group(1));
if(mat2.find())
downloader.driveLinks.add(mat2.group(1));
if(mat3.find())
downloader.zippyShareLinks.add(mat3.group(1));
}
}
});
Expand Down Expand Up @@ -399,12 +403,17 @@ public void actionPerformed(ActionEvent e) {
{
Pattern pat1 = Pattern.compile("(https:\\/\\/mega\\S+)");
Pattern pat2 = Pattern.compile("(https:\\/\\/drive\\S+)");
Pattern pat3 = Pattern.compile("(https:\\/\\/www\\d\\S+)");
Matcher mat1 = pat1.matcher(scraper.episodes.get(epComboBox.getSelectedIndex()-1).getAttribute("data-links"));
Matcher mat2 = pat2.matcher(scraper.episodes.get(epComboBox.getSelectedIndex()-1).getAttribute("data-links"));
Matcher mat3 = pat3.matcher(scraper.episodes.get(epComboBox.getSelectedIndex()-1).getAttribute("data-links"));
if(mat1.find())
downloader.megaLinks.add(mat1.group(1));
if(mat2.find())
downloader.driveLinks.add(mat2.group(1));
if(mat3.find())
downloader.zippyShareLinks.add(mat3.group(1));
System.out.println(downloader.zippyShareLinks);
loading ld4 = new loading(4);
ld4.execute();
}
Expand Down
1 change: 0 additions & 1 deletion src/AnimeNinja/scraper.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ protected static ArrayList<String> getEpisodes() //returns an Array containing

}
ArrayList<String> episodeNumbers = new ArrayList<String>();
downloader.megaLinks.removeAll(downloader.megaLinks);
episodes = driver.findElements(By.cssSelector(".selective select option"));
Collections.reverse(episodes);
for(int i=0 ; i<episodes.size() ; i++)
Expand Down

0 comments on commit 745cd72

Please sign in to comment.