Skip to content
This repository has been archived by the owner on Jul 6, 2022. It is now read-only.

Version 2, ridding of reliance on web-service #6

Merged
merged 16 commits into from
Dec 12, 2017
Merged

Version 2, ridding of reliance on web-service #6

merged 16 commits into from
Dec 12, 2017

Conversation

IT-MikeS
Copy link
Contributor

@IT-MikeS IT-MikeS commented Dec 5, 2017

Putting all changes from v2 branch into new master branch pull request.

Done:

  • swap to module to do downloading and conversion on computer instead of using a web-service.

Needs doing:

  • Testing on platforms other than windows
  • Create user setting type store where a folder can be set as the download destination to improve flow for user.
  • Better comment code to reflect changes made to get to 2.x.x
  • Set application to use users platform default downloads folder as default store for converted files.

@IT-MikeS IT-MikeS mentioned this pull request Dec 5, 2017
IT-MikeS added 2 commits December 5, 2017 10:33
…ation so download and conversion are separated progress bars, set path for downloaded file to platform default downloads folder.
…ation so download and conversion are separated progress bars, set path for downloaded file to platform default downloads folder with display for user.
@IT-MikeS
Copy link
Contributor Author

IT-MikeS commented Dec 5, 2017

Update

Added:

  • Converted files go automatically to the appropriate platforms downloads folder.
  • Added local conversion function that I had forgot before so now files actually get turned into mp3
  • Separated the progress for download and conversion, downloading to 100% then converting to 100%

Currently working on:

  • Allowing user to set a default folder that will persist through application exit and re-open.
  • Creating better error handling and testing possible common errors.
  • Progressively commenting and refactoring to clean up names and make everything more understandable

Needs doing that I can not accomplish:

  • Testing application on other platforms

@IT-MikeS
Copy link
Contributor Author

IT-MikeS commented Dec 6, 2017

Update

Added:

  • Function to allow user to set a default folder that will persist through application exit and re-open.
  • Some more comments

Copy link
Owner

@leerob leerob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems much more complicated than what we were doing previously... could you explain the advantages of doing this? Specifically getting and mp4 and then converting it to mp3 versus using yt-mp3.

@@ -93,3 +95,11 @@ body {
cursor: pointer;
}
}

.outputFolderDisplay {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to use BEM naming, otherwise use hypen-case versus camelCase.

Copy link
Contributor Author

@IT-MikeS IT-MikeS Dec 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I'll make the adjustment

return <ProgressBar progress={this.state.progress} messageText={this.state.progressMessage}/>;
return (
<div>
<div className="outputFolderDisplay">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be the same code in both the if and else block. Maybe we can make a new React component for this code? Something like OutputFolder.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was thinking about that too, still fiddling with react but I'll get it there

<div>
<div className="outputFolderDisplay">
<a href='#' onClick={this.changeOutputFolder}>Change</a>
<span>&nbsp;&nbsp;Current output folder:&nbsp;</span>{this.state.userDownloadsFolder}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to use CSS padding versus &nbsp;&nbsp;?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is more just for now working on fixing this

return (
<div>
<div className="outputFolderDisplay">
<a href='#' onClick={this.changeOutputFolder}>Change</a>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you even need to put # if there's not actually a link? I'm not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do, but I'm not sure either

Copy link
Contributor Author

@IT-MikeS IT-MikeS Dec 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the answer is no, but without it there is no "link" style to the "a" tag so I'll just remove the href and add css styling

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quite like the css I put on it better than the default look of a html link and no need for class just style the a tag inside of containing element

let fileSelector = remote.dialog.showOpenDialog({properties: ['openDirectory'], title: 'Select folder to store files.'});

// If a folder was selected and not just closed, set the localStorage value to that path and adjust the state.
if(fileSelector) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a space between if and the ( e.g.

if (fileSelector)

progress: Math.floor(progress)
});
changeOutputFolder() {
// Create an electron open dialog for selecting folders, this will take into account platform
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Prefer to end comments that read as sentences with a period.

this.setState({progressMessage: 'Converting...', progress: 0});

return new Promise((resolve, reject) => {
// reset the rate limiting trigger just encase.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Prefer to start inline comments with a capital letter.

@IT-MikeS
Copy link
Contributor Author

IT-MikeS commented Dec 7, 2017

The main benefit of using this over yt-mp3 is that we were bound to that service, this limits you in a few significant ways.

  • If they disappear the app breaks
  • They have only so many "workers" on their server which can lead to long wait times to download and convert a video
  • Progress tracking on the web-service can be spotty
  • Any time their API changes the app needs an update

As for why we download an mp4 then convert it to mp3: this is more of a limitation workaround, youtube videos provide audio in mp4 format, we could download this and leave it there, and most modern players and software will be able to read it, but we convert to mp3 to ensure the greatest compatibility across players and platforms.

@leerob
Copy link
Owner

leerob commented Dec 7, 2017 via email

Copy link
Owner

@leerob leerob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to pull things down and test them out. Everything appeared to work as excepted. I like having the two different loading bars for downloading and converting, good idea.

I think instead of saying Conversion successful! Resetting in 5 seconds, we can just say Conversion successful! and reset after 1 second.

I'm sorry I didn't articulate this more clearly earlier, but I guess what I had in mind for the folder selection was to have it hidden in a menu. That way it wasn't modifying the UI at all. So in the menu bar there could be a "Preferences" option and underneath that would be a "Download Folder" option. Clicking that would pop the modal asking for the location and then continue to save it to local storage like such.

That would prevent us from having the text at the bottom of the application. I want to keep the UI very simple. I think it's okay that it doesn't show which folder it's downloading to.

@@ -4,6 +4,7 @@ import ProgressBar from '../components/ProgressBar';
const ytdl = window.require('ytdl-core');
const fs = window.require('fs-extra');
import * as path from 'path';
import OutputPath from "../components/OutputPath";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these imports be ordered? https://eslint.org/docs/rules/sort-imports

@IT-MikeS
Copy link
Contributor Author

IT-MikeS commented Dec 8, 2017

No worries, now hearing it, I like your idea for the output folder settings better. As for the conversion successful message your modification makes sense, I'll make both these changes as soon as I can and the sort order changes too

…u item, and app now resets after 1 second after successful download and conversion.
@IT-MikeS
Copy link
Contributor Author

IT-MikeS commented Dec 8, 2017

I made all the modifications in your last comment and I think it looks and feels very good, great suggestions!


// If a folder was selected and not just closed, set the localStorage value to that path and adjust the state.
if (fileSelector) {
let pathToStore = fileSelector[0];
localStorage.setItem('userSelectedFolder', pathToStore);
this.setState({userDownloadsFolder: pathToStore});
console.log(`New current path ${localStorage.getItem('userSelectedFolder')}`)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably isn't needed anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah just forgot to take the log out lol

@leerob
Copy link
Owner

leerob commented Dec 8, 2017

Do you happen to know what bitrate the mp3s get converted to?

Anyways, just tested everything and I totally agree. The menu option is awesome! I tried downloading short, medium, and long length videos. They all worked really well! Super excited that this now support videos that are 1 hour long. Maybe I'll test it with something that's like a day long haha.

Nice work on this! 🎉

@leerob
Copy link
Owner

leerob commented Dec 8, 2017

image

Did you have any trouble packaging the app? It's saying it can't find the logo file, but it is definitely there.

@IT-MikeS
Copy link
Contributor Author

IT-MikeS commented Dec 8, 2017

For the answer to the bitrate: its a value we can set in the ffmpeg lib, right now its at 160 (cd quality)

As for the packaging issue, its the path to the icon, pushing a update that should resolve this.

@IT-MikeS
Copy link
Contributor Author

IT-MikeS commented Dec 8, 2017

That should resolve the issue you were having

@IT-MikeS
Copy link
Contributor Author

Test building on windows, and tested with 24 hour video all is working well here

@leerob
Copy link
Owner

leerob commented Dec 12, 2017

Looks good to me! This should allow the user to easily change bitrates from a menu option in the future as well, which is nice 🎉

@leerob leerob merged commit a866db1 into leerob:master Dec 12, 2017
@IT-MikeS
Copy link
Contributor Author

That's what I thought too, was going to work on download queue and better preferences menu, what do you think?

@leerob
Copy link
Owner

leerob commented Dec 12, 2017 via email

@IT-MikeS
Copy link
Contributor Author

Okay i'll work on it, as for electron-dl, I like the idea but I think we'll need to modify it a bit to make it work with youtube videos

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants