From a0f946d62e9f9b9e35183b1778875524cae3f797 Mon Sep 17 00:00:00 2001 From: plane000 Date: Sun, 29 Jul 2018 18:34:01 +0100 Subject: [PATCH] youtube downloader --- .../Evaluate mathematical expressions.sln | 25 ++++++++ .../App.config | 6 ++ .../Evaluate mathematical expressions.csproj | 52 +++++++++++++++++ .../Program.cs | 57 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++++++++ JavaScript/calculator/index.html | 43 ++++++++++++++ JavaScript/calculator/index.js | 3 + JavaScript/calculator/style.css | 38 +++++++++++++ JavaScript/youtube-dowloader/index.js | 40 +++++++++++++ .../youtube-dowloader/package-lock.json | 47 +++++++++++++++ JavaScript/youtube-dowloader/package.json | 15 +++++ JavaScript/youtube-dowloader/videos.txt | 9 +++ 12 files changed, 371 insertions(+) create mode 100644 C#/Evaluate mathematical expressions/Evaluate mathematical expressions.sln create mode 100644 C#/Evaluate mathematical expressions/Evaluate mathematical expressions/App.config create mode 100644 C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Evaluate mathematical expressions.csproj create mode 100644 C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Program.cs create mode 100644 C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Properties/AssemblyInfo.cs create mode 100644 JavaScript/calculator/index.html create mode 100644 JavaScript/calculator/index.js create mode 100644 JavaScript/calculator/style.css create mode 100644 JavaScript/youtube-dowloader/index.js create mode 100644 JavaScript/youtube-dowloader/package-lock.json create mode 100644 JavaScript/youtube-dowloader/package.json create mode 100644 JavaScript/youtube-dowloader/videos.txt diff --git a/C#/Evaluate mathematical expressions/Evaluate mathematical expressions.sln b/C#/Evaluate mathematical expressions/Evaluate mathematical expressions.sln new file mode 100644 index 0000000..05535a3 --- /dev/null +++ b/C#/Evaluate mathematical expressions/Evaluate mathematical expressions.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27428.2043 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Evaluate mathematical expressions", "Evaluate mathematical expressions\Evaluate mathematical expressions.csproj", "{5DF49706-2223-4A81-9565-29DDBA1FABE8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5DF49706-2223-4A81-9565-29DDBA1FABE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5DF49706-2223-4A81-9565-29DDBA1FABE8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5DF49706-2223-4A81-9565-29DDBA1FABE8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5DF49706-2223-4A81-9565-29DDBA1FABE8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6B5F9ED2-21EE-45F9-BB00-C01860D5F8E1} + EndGlobalSection +EndGlobal diff --git a/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/App.config b/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/App.config new file mode 100644 index 0000000..731f6de --- /dev/null +++ b/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Evaluate mathematical expressions.csproj b/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Evaluate mathematical expressions.csproj new file mode 100644 index 0000000..10b9351 --- /dev/null +++ b/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Evaluate mathematical expressions.csproj @@ -0,0 +1,52 @@ + + + + + Debug + AnyCPU + {5DF49706-2223-4A81-9565-29DDBA1FABE8} + Exe + Evaluate_mathematical_expressions + Evaluate mathematical expressions + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Program.cs b/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Program.cs new file mode 100644 index 0000000..f5cfc1a --- /dev/null +++ b/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Program.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Evaluate_mathematical_expressions { + class Program { + static void Main(string[] args) { + + } + } + + public class MathEvaluator { + public static void Run() { + Eval("(1+2)"); + Eval("5*4/2"); + Eval("((3+5)-6)"); + } + + public static void Eval(string input) { + var ans = Evaluate(input); + Console.WriteLine(input + " = " + ans); + } + + public static double Evaluate(String input) { + String expr = "(" + input + ")"; + Stack ops = new Stack(); + Stack vals = new Stack(); + + for (int i = 0; i < expr.Length; i++) { + String s = expr.Substring(i, 1); + if (s.Equals("(")) { } else if (s.Equals("+")) ops.Push(s); + else if (s.Equals("-")) ops.Push(s); + else if (s.Equals("*")) ops.Push(s); + else if (s.Equals("/")) ops.Push(s); + else if (s.Equals("sqrt")) ops.Push(s); + else if (s.Equals(")")) { + int count = ops.Count; + while (count > 0) { + String op = ops.Pop(); + double v = vals.Pop(); + if (op.Equals("+")) v = vals.Pop() + v; + else if (op.Equals("-")) v = vals.Pop() - v; + else if (op.Equals("*")) v = vals.Pop() * v; + else if (op.Equals("/")) v = vals.Pop() / v; + else if (op.Equals("sqrt")) v = Math.Sqrt(v); + vals.Push(v); + + count--; + } + } else vals.Push(Double.Parse(s)); + } + return vals.Pop(); + } + } +} diff --git a/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Properties/AssemblyInfo.cs b/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..04b35e3 --- /dev/null +++ b/C#/Evaluate mathematical expressions/Evaluate mathematical expressions/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Evaluate mathematical expressions")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Evaluate mathematical expressions")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5df49706-2223-4a81-9565-29ddba1fabe8")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/JavaScript/calculator/index.html b/JavaScript/calculator/index.html new file mode 100644 index 0000000..38d7091 --- /dev/null +++ b/JavaScript/calculator/index.html @@ -0,0 +1,43 @@ + + + + + + + + Calculator + + + +
+ +
+ +
AC
+
C
+ +
+
+ +
7
+
8
+
9
+
÷
+ +
4
+
5
+
6
+
x
+ +
1
+
2
+
3
+
-
+ +
0
+
.
+
=
+
+
+
+ + diff --git a/JavaScript/calculator/index.js b/JavaScript/calculator/index.js new file mode 100644 index 0000000..246a39c --- /dev/null +++ b/JavaScript/calculator/index.js @@ -0,0 +1,3 @@ +function ac() { + console.log('ac'); +} \ No newline at end of file diff --git a/JavaScript/calculator/style.css b/JavaScript/calculator/style.css new file mode 100644 index 0000000..cc97631 --- /dev/null +++ b/JavaScript/calculator/style.css @@ -0,0 +1,38 @@ +@import url('https://fonts.googleapis.com/css?family=Roboto:400,100'); + +body { + -webkit-background-size: cover; + -moz-background-size: cover; + -o-background-size: cover; + background-size: cover; + background: rgb(245, 245, 245); + font-family: 'Roboto', sans-serif; + color: #2f2f2f +} + +.calc-container { + display: grid; + grid-template-columns: 100px 100px 100px 100px; + width: 400px; + background-color: rgb(122, 184, 255); + padding: 10px; +} + +.calc-display { + width: 395px; + height: 70px; + padding-bottom: 20px; + resize: none; +} + +.calc-item { + background-color: rgb(228, 228, 228); + border: 1px solid #2f2f2f; + padding: 20px; + font-size: 30px; + text-align: center; +} + +.calc-item:hover { + background-color: rgb(195, 195, 195); +} diff --git a/JavaScript/youtube-dowloader/index.js b/JavaScript/youtube-dowloader/index.js new file mode 100644 index 0000000..4af58cd --- /dev/null +++ b/JavaScript/youtube-dowloader/index.js @@ -0,0 +1,40 @@ +const fs = require('fs'); +const ytdl = require('ytdl-core'); + +let videos = []; + +if (!fs.existsSync('./videos.txt')) { + console.log('Could not find videos.txt, make sure it exists and has youtube links, each on new lines'); + process.exit(); +} + +let text = fs.readFileSync('./videos.txt').toString(); +text.split('\n').forEach((line) => { + videos.push(line.replace(/\r/, '')); +}); + +videos.forEach((url) => { + if (ytdl.validateURL(url)) { + ytdl.getInfo(url, (err, info) => { + if (err) { + console.log(`An error occured while downloading '${url}'`) + } else { + let title = info.title; + + try { + let stream = ytdl(url, {quality: 'highest'}).pipe(fs.createWriteStream(`${title}.mp4`)); + stream.on('finish', () => console.log(`Finish downloading ${title}`)); + } catch (e) { + console.log(`An error occured while downloaing '${title}' retrying`) + try { + let stream = ytdl(url, {quality: 'highest'}).pipe(fs.createWriteStream(`${title}.mp4`)); + stream.on('finish', () => console.log(`Finish downloading '${title}'`)); + } catch (e) { + console.log(`Unable to download '${title}'`) + } + } + console.log(`Downloading '${title}'`); + } + }) + } else console.log(`Video ${url} was not found`); +}); diff --git a/JavaScript/youtube-dowloader/package-lock.json b/JavaScript/youtube-dowloader/package-lock.json new file mode 100644 index 0000000..06a5410 --- /dev/null +++ b/JavaScript/youtube-dowloader/package-lock.json @@ -0,0 +1,47 @@ +{ + "name": "youtube-dowloader", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" + }, + "html-entities": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz", + "integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8=" + }, + "m3u8stream": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/m3u8stream/-/m3u8stream-0.3.0.tgz", + "integrity": "sha512-0tvjXDIa6BolPEGo9zioQiPqfQhjopZXN3L7vZH/rZQCOLd4rPXNZc1UBMdW3TRpjNBoD0+F1X41/f0iY23rlQ==", + "requires": { + "miniget": "1.2.0" + } + }, + "miniget": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/miniget/-/miniget-1.2.0.tgz", + "integrity": "sha1-ADY3Oia71S2+aUX85sjAOR6eEkE=" + }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, + "ytdl-core": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-0.21.1.tgz", + "integrity": "sha512-K6ysXuHW0X3MgeLpO4IHvHp5gdF2DDrgFPP7kQODBSpeaq4+/y8lvWy6ZpxtJdQGE0+GUaBZ2H1/kYcP327UdQ==", + "requires": { + "html-entities": "1.2.1", + "m3u8stream": "0.3.0", + "miniget": "1.2.0", + "sax": "1.2.4" + } + } + } +} diff --git a/JavaScript/youtube-dowloader/package.json b/JavaScript/youtube-dowloader/package.json new file mode 100644 index 0000000..2b8be26 --- /dev/null +++ b/JavaScript/youtube-dowloader/package.json @@ -0,0 +1,15 @@ +{ + "name": "youtube-dowloader", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Ben (plane000)", + "license": "MIT", + "dependencies": { + "fs": "0.0.1-security", + "ytdl-core": "^0.21.1" + } +} diff --git a/JavaScript/youtube-dowloader/videos.txt b/JavaScript/youtube-dowloader/videos.txt new file mode 100644 index 0000000..632ba61 --- /dev/null +++ b/JavaScript/youtube-dowloader/videos.txt @@ -0,0 +1,9 @@ +https://www.youtube.com/watch?v=Np1dc0BoS4k&list=PL8flSFeCsFvJhFpz0usI6diGT2stP8WF1 +https://www.youtube.com/watch?v=YoIMP57as4A&list=PL8flSFeCsFvJhFpz0usI6diGT2stP8WF1&index=2 +https://www.youtube.com/watch?v=8ys_n86INW0&index=3&list=PL8flSFeCsFvJhFpz0usI6diGT2stP8WF1 +https://www.youtube.com/watch?v=78nD9HeN2wU&index=4&list=PL8flSFeCsFvJhFpz0usI6diGT2stP8WF1 +https://www.youtube.com/watch?v=2HlgmpcYrKs&list=PL8flSFeCsFvJhFpz0usI6diGT2stP8WF1&index=5 +https://www.youtube.com/watch?v=mNJjJ5JjQdc&list=PL8flSFeCsFvJhFpz0usI6diGT2stP8WF1&index=6 +https://www.youtube.com/watch?v=-zK-sOTujMc&list=PL8flSFeCsFvJhFpz0usI6diGT2stP8WF1&index=7 +https://www.youtube.com/watch?v=vRUh0XNORiY&list=PL8flSFeCsFvJhFpz0usI6diGT2stP8WF1&index=8 +https://www.youtube.com/watch?v=Z3ZqRVrHAbY&list=PL8flSFeCsFvJhFpz0usI6diGT2stP8WF1&index=9 \ No newline at end of file