Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
SaptarshiSarkar12 committed Oct 23, 2022
2 parents f54e604 + 92e95c6 commit 3d3a273
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 37 deletions.
8 changes: 4 additions & 4 deletions Drifty.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
<runtimeBits>64/32</runtimeBits>
</jre>
<versionInfo>
<fileVersion>1.2.0.0</fileVersion>
<txtFileVersion>1.1.0.0</txtFileVersion>
<fileVersion>1.2.1.0</fileVersion>
<txtFileVersion>1.2.0.0</txtFileVersion>
<fileDescription>Drifty is an open-source interactive File Downloader system built with java.</fileDescription>
<copyright>Copyright © 2022 - 32 Saptarshi Sarkar</copyright>
<productVersion>1.2.0.0</productVersion>
<txtProductVersion>1.1.0.0</txtProductVersion>
<productVersion>1.2.1.0</productVersion>
<txtProductVersion>1.2.0.0</txtProductVersion>
<productName>Drifty</productName>
<companyName></companyName>
<internalName>Drifty CLI</internalName>
Expand Down
Binary file modified Drifty_CLI.exe
Binary file not shown.
19 changes: 10 additions & 9 deletions Website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<link rel="icon" type="image/png" sizes="32x32" href="./favicons/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="./favicons/favicon-16x16.png" />
<link rel="manifest" href="./favicons/site.webmanifest" />
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
</head>

<body>
Expand Down Expand Up @@ -107,13 +108,12 @@ <h2 class="text-gradient-blue">Be a part of Drifty Family!</h2>
<h4>✨Download Here✨</h4>
</div>
<div id="download_section" class="download_section">
<a onclick="download_alert_window()"
class="btn4">Download Now <i class="fab fa-windows"></i></a>
<a onclick="download_alert_window()" class="btn4">Download Now <i class="fab fa-windows"></i></a>
<a onclick="download_alert_apple()" class="btn4">Download
Now <i class="fab fa-apple"></i> <i class="fab fa-linux"></i></a>
</div>
<span><b>All releases</b></span>
<div id="releases" class="release_section">
<div id="releases" class="release_section">


</div>
Expand All @@ -134,18 +134,18 @@ <h2>Contact Us</h2>
<a href="https://github.com/SaptarshiSarkar12/Drifty/discussions" type="button">
<i class="fa-solid fa-headset"></i> Support
</a>

<a href="mailto:saptarshi.programmer@gmail.com" type="button"><i class="fa-sharp fa-solid fa-envelope"></i>
Email</a>
</div>
</section>

<footer class="footer">
<div class="social">
<a href="https://www.twitter.com/SSarkar2007" id="twitter"><i class="fab fa-twitter"></i></a>
<a href="https://github.com/SaptarshiSarkar12" ><i class="fab fa-github"></i></a>
<a href="https://saptarshisarkar.hashnode.dev/"><i class="fa-brands fa-hashnode"></i></a>
<a href="https://www.bio.link/saptarshi" ><i class="fa-sharp fa-solid fa-link"></i></a>
<a href="https://www.twitter.com/SSarkar2007" id="twitter"><i class="fab fa-twitter"></i></a>
<a href="https://github.com/SaptarshiSarkar12"><i class="fab fa-github"></i></a>
<a href="https://saptarshisarkar.hashnode.dev/"><i class="fa-brands fa-hashnode"></i></a>
<a href="https://www.bio.link/saptarshi"><i class="fa-sharp fa-solid fa-link"></i></a>
<!--added footers -->
</div>
<p><i class="fa-solid fa-copyright"></i> Drifty
Expand All @@ -155,4 +155,5 @@ <h2>Contact Us</h2>
<!-- Scripts -->
<script src="script.js"></script>
</body>
</html>

</html>
75 changes: 59 additions & 16 deletions Website/script.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
"use strict";

/* Javascript alert */
function download_alert_window(){
var w = confirm("Do you want to Downlaod");
if(w==true){
function download_alert_window() {
var w = confirm("Do you want to download Drifty?");
if (w == true) {
alert("Thanks for Downloading");
window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty_CLI.exe");
}
else{
window.open(
"https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty_CLI.exe"
);
} else {
alert("Sorry! You cancelled the Download!");
}
}

function download_alert_apple(){
var a = confirm("Do you want to Downlaod");
if(a==true){
function download_alert_apple() {
var a = confirm("Do you want to download Drifty?");
if (a == true) {
alert("Thanks for Downloading");
window.open("https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty.jar");
}
else{
window.open(
"https://github.com/SaptarshiSarkar12/Drifty/releases/latest/download/Drifty.jar"
);
} else {
alert("Sorry! You cancelled the Download!");
}
}


const date = new Date();

let darkMode = localStorage.getItem("darkMode");
Expand Down Expand Up @@ -154,11 +155,22 @@ else if (currentHour - releasesRequestedAt >= 4)
getReleases(); // get release info every 4 hours
else updateReleases();

// latest release could be defined as release with higher id;
function setLatest(releases) {
let maxiId = Math.max(...releases.map((re) => re.id));
releases = releases.map((release) => {
release.isLatest = release.id == maxiId;
return release;
});
return releases;
}

function getReleases() {
fetch("https://api.github.com/repos/SaptarshiSarkar12/Drifty/releases")
.then((x) => x.json())
.then((data) => {
releases = data;
releases = setLatest(releases);
localStorage.setItem("releases", JSON.stringify(data));
localStorage.setItem("releasesRequestedAt", date.getHours());
updateReleases();
Expand All @@ -180,17 +192,48 @@ function renderReleases(releases) {
}

function renderRelease(all, release) {
console.log(release);
release.totalCount = release.assets.reduce(
(total, rel) => total + rel.download_count,
0
);
let assets = renderAssets(release.assets.reverse());
return `${all} <div class="release">
<div><b>${release.name}</b></div>
<div>${new Date(release.published_at)}</div>
<div style="text-align:center"><b>${release.name}</b> ${
release.isLatest ? "<b class='label'>Latest</b>" : ""
}</div>
<div style="text-align:center">${new Date(release.published_at)} with <b>${
release.totalCount
} </b> Downloads</div>
<div onclick="toggleMore(this,'${
release.id
}')" style="text-align:center;cursor:pointer;font-weight:bolder;opacity: 0.4;">Learn More</div>
<div id="${release.id}" class="release-note">
${marked.parse(release.body)}
</div>
<div class="assets">
${assets}
</div>
</div>`;
}

function toggleMore(btn, id) {
let release_note = document.getElementById(id);
// calculate the real height of the element which is scrollHeight + margin(1rem top and 1 rem bottom) + border(0)
// let height = release_note.scrollHeight + parseFloat( getComputedStyle(document.documentElement).fontSize.split("px")[0] ) *2;
// or simply we could multiply the scroll height by two and the height could not be more that this
let height = release_note.scrollHeight * 2;

if (btn.innerText == "Hide") {
release_note.style.maxHeight = "0px";
release_note.style.margin = "0rem";
btn.innerText = "Learn More";
} else {
release_note.style.maxHeight = height + "px";
release_note.style.margin = "1rem";
btn.innerText = "Hide";
}
}

function renderAssets(assets) {
return assets.reduce((all, asset) => {
//check if it is for windows
Expand Down
31 changes: 31 additions & 0 deletions Website/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ header {
flex-direction: column;
justify-content: center;
text-align: left;
max-width: min(100%,max(50%,500px));
}

.release{
Expand Down Expand Up @@ -970,3 +971,33 @@ header {
.lightTxt {
display: none;
}

.release-note {
overflow: hidden;
transition: max-height 200ms;
max-height: 0;
text-align: center;
}

.release-note a, .release-note li {
color: var(--black);
}
.release h2, .release h3{
color: var(--text-color);;
}
.release ul{
margin-left:2rem;
text-align: left;
}
.label{
display: inline-block;
padding: 0 7px;
font-size: 12px;
font-weight: 500;
line-height: 18px;
white-space: nowrap;
border: 1px solid transparent;
border-radius: 2em;
background-color: #4caf50;
color: var(--font-color);
}
Binary file modified out/artifacts/Drifty_CLI_jar/Drifty.jar
Binary file not shown.
Binary file modified out/production/Drifty/Drifty_CLI.class
Binary file not shown.
Binary file modified out/production/Drifty/FileDownloader.class
Binary file not shown.
15 changes: 12 additions & 3 deletions src/Drifty_CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public class Drifty_CLI {
*/
public static void main(String[] args) {
logger.log("INFO", "Application Started !");
if (!flag) {
printBanner();
}
initialPrintBanner();
flag = true;
if (args.length > 0){
String URL = args[0];
Expand Down Expand Up @@ -250,4 +248,15 @@ private static void printBanner(){
System.out.println(ANSI_CYAN+" |_____/ |_| \\_\\|_____||_| |_| |_| "+ANSI_RESET);
System.out.println(ANSI_PURPLE+"===================================================================="+ANSI_RESET);
}

private static void initialPrintBanner(){
System.out.println("====================================================================");
System.out.println(" _____ _____ _____ ______ _______ __ __");
System.out.println(" | __ \\ | __ \\ |_ _|| ____||__ __|\\ \\ / /");
System.out.println(" | | | || |__) | | | | |__ | | \\ \\_/ /");
System.out.println(" | | | || _ / | | | __| | | \\ / ");
System.out.println(" | |__| || | \\ \\ _| |_ | | | | | | ");
System.out.println(" |_____/ |_| \\_\\|_____||_| |_| |_| ");
System.out.println("====================================================================");
}
}
15 changes: 10 additions & 5 deletions src/FileDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,23 @@ public void run() {
//If link is from YouTube
if (Drifty_CLI.isYoutubeLink(link)) {
//download youtube video
System.out.println("Downloading ...");
Drifty_CLI.logger.log("INFO", "Downloading ...");
System.out.println("Trying to download the file ...");
Drifty_CLI.logger.log("INFO", "Trying to download the file ...");

try {
ProcessBuilder processBuilder = new ProcessBuilder("yt-dlp", "--quiet", "--progress", "-P", dir, link);
processBuilder.inheritIO();
Process yt_dlp = processBuilder.start();

yt_dlp.waitFor();

System.out.println("\nDONE");
Drifty_CLI.logger.log("INFO", "Successfully downloaded the file");
int exitValueOfYt_Dlp = yt_dlp.exitValue();
if (exitValueOfYt_Dlp == 0){
System.out.println("Successfully downloaded the file!");
Drifty_CLI.logger.log("INFO", "Successfully downloaded the file!");
} else if (exitValueOfYt_Dlp == 1) {
System.out.println("Failed to download the file!");
Drifty_CLI.logger.log("INFO", "Failed to download the file!");
}

} catch (Exception e) {
e.printStackTrace();
Expand Down

0 comments on commit 3d3a273

Please sign in to comment.