jansmolders86 / mediacenterjs

A HTML/CSS/Javascript (NodeJS) based Media center
http://mediacenterjs.com
1.29k stars 243 forks source link

Abstract away from the database #133

Closed Jon889 closed 9 years ago

Jon889 commented 10 years ago

I'm currently adding a hidden field to the Movies app, and it's a bit of a pain adding a column to the table with data already in the table. I've looked at jugglingdb at it seems it would make things like this a lot easier?

jansmolders86 commented 10 years ago

Feel free to change the database sturcture. Or Atleast the table structure. The project is still in alpha so its only natural these things are still subject to change. I'm going to add release notes to the auto update functionality so people will be apprised if they need to drop their current db.

Ps, jugglindb looks like a great find. How is your experience with it so far?

Jon889 commented 10 years ago

It's made a bit of the code simpler (I've switched the movies app to it in the jugglingdb branch). I'm now trying switching the music app, and not sure how to proceed. When requesting all the albums should I include the tracks in an array in each album or have request for each album to get its tracks.

jansmolders86 commented 10 years ago

You are right. Currently I add an array of tracks to the album info. It's probably the most versatile solution. We can simply not show the album info if need be. What do you think?

BTw, I took a look at the branch. I love the separation of concerns! It really simplifies the code a lot by using this abstraction layer for the database schema's! Might I suggest adding a folder in Utils called schema's and add all the various schema's?

Jon889 commented 10 years ago

The schema in separate files is a good idea. I'm finding the problem with jugglingdb is that it doesn't seem quite complete. Also the documentation isn't amazing. I've looked at sequelize and it looks quite a bit better, with more features and better documentation. So I think it would be better to try that instead of jugglingdb?

Also I was thinking about separating the artist from the album in music but then this causes a bit of dilemma when editing an Album's Info on the front end, as in is the user trying to change the artist's name across all their albums, or move the album to a different artist? (Though, it may make more sense to attach artist to the track as some albums have tracks from different artists, such as movie soundtracks)

Jon889 commented 10 years ago

I think i've finished moving the apps and Devices to sequelize in it's branch, still needs tidying up though. Do you want to take a look and see if it's basically right? i'm not too convinced about the TV app, because I've only got one episode downloaded.

jansmolders86 commented 10 years ago

For sure! I'll let you know if I find anything :)

jansmolders86 commented 10 years ago

Ok, so I pushed two commits to the sequilize branch. Both concerning the package json. Just minor stuff. The "apps" work! especially the movie app worked out of the box. Unfourtunatly I did have some small issues:

I also get this error:

C:\Users\jan.smolders\Documents\GitHub\mediacenterjs\node_modules\sqlite3\lib\trace.js:28
                throw err;
                      ^
TypeError: Cannot call method 'json' of undefined
     at null.<anonymous> (C:\Users\jan.smolders\Documents\GitHub\mediacenterjs\apps\tv\tv-functions.js:39:17)

Is that enough info for you?

Jon889 commented 10 years ago

Thanks, I messed up the merge of the package.json, sorry about that, i thought I'd tested it but obviously hadn't :/

About the music app I changed the supported filetype to m4a because I used my iTunes library, and forgot to change it back to mp3, that's the only thing I can think is the problem because it loads on my setup?

And thanks, I just fixed the duplicate shows and turned off the SQL logging. I'm quite confused about that error, because that is the res.json(); so it means the response that originally comes from express is undefined?

jansmolders86 commented 10 years ago

No need to say sorry my friend. Thanks for the fixes! We should probably extend the music player so it supports both. The error is raised during the automated scraping I found out. Hence res is undefined.

jansmolders86 commented 10 years ago

Hey Jonathan,

Sorry it took me a while to get back to you. I checked out your changes in the sequilize branch and the TV appp works great now!

Sadly though, nothing seems to happen when I open the music app. I do not see anthing in the log either. It just sits there on the loading screen.

I saw you uncommented the progression marker. Is that still a todo? Or do you want to scratch that functionality?

Jon889 commented 10 years ago

I think that may be because of the mp3/m4a thing. I haven't changed it back in the sequelize branch yet. Though it should say if there are no files found. I've just commented out the progression marker temporarily, I removed the old db requires, so had to comment it out. I've not had as much time the last week, but have slowly been converting it.

jansmolders86 commented 10 years ago

Of course! I only just now realized the mp3/m4a support commit was done in master. My apologies!

Take your time Jonathan! I'm very thankful you are helping. I'm currently redesigning some stuff, so once that's done and the abstraction layer is done, this thing can go into beta mode! :)

Jon889 commented 10 years ago

Sounds good :)

Slightly annoying but I realised today that changing the model definitions in sequelize isn't quite as simple as in jugglingdb, though it has migrations so it's still easier than if using SQL directly.

Jon889 commented 10 years ago

Pretty sure the sequelize is all done now, at least i've all the traces of dblite, and nothing [seems to be] broke.

jansmolders86 commented 10 years ago

Let be do one last check and then we'll merge and we'll almost be ready for the beta release! :)

jansmolders86 commented 10 years ago

Hey Jonathan,

I found one last issue. Basically the same as with the tv show thing. Currently, not all the album's are merged, so I have multiple versions of the same album with separate tracks even though the album name/artist is seemingly identical.

I believe that is the only issue left :)!

Great job Jonathan! I could not have done this without you!

Jon889 commented 10 years ago

I think I have fixed that now, by parsing the tracks in series, not parallel.

jansmolders86 commented 10 years ago

That's awesome Jonathan! I committed some styling tweaks and template tweaks in the sequelize. I did it because the tweaks are largely based on the sequelize data. hope you don't mind.

The last think I was working on but did not yet finish was showing the tracks in their proper order.

Jon889 commented 10 years ago

No, it looks good :) though the bar at the bottom of the movie poster is a bit bright now I think? (Also the backgrounds of the app icons on the main page?)

I think angular has an order by filter and I think each track has it's track number so it should be quite simple to add ordering?

Jon889 commented 10 years ago

I find now when adding something to the music app playlist it replaces the currently added item, because of this line

(if I comment it out and then add multiple items then all album images stay at the top of the playlist leaving large gaps where they should.)

Or is the intention to make the playlist sidebar just show a list of tracks of the clicked album? In which case it should probably be renamed, and the disallow adding single tracks to it.

Also what is the need for the playlist.currentAlbum/currentCover here? This can be accessed from the track?

jansmolders86 commented 10 years ago

Very insightful comments Jonathan,

I will push a commit to remedy most of your well reasoned issues.

I would like to split the playlist functionality a bit if you think that works. So what I mean is that it was possible previously to add multiple albums in the playlist underneath each other. although that's nice in theory, it doesn't work intuitive and is a bit weird frankly so I removed this option. Of course, this still is the desired functionality for separate tracks. So I would like to split those flows.

I also removed the background images from the movies app for now. I will add a more classic XMBC view later where we can re enabled the backdrops.

Jon889 commented 10 years ago

Splitting them sounds great, I too thought it was a bit odd adding whole albums. Perhaps have completely separate sidebars? One for an album view and one for a playlist? Or even not have the album view in a sidebar, maybe something like iTunes?

jansmolders86 commented 10 years ago

Yup I completely agree! we might not even need a sidebar at all when switching to the track view! I'm so happy you're so good at looking beyond what is in front of you and think outside the box! :)

jansmolders86 commented 10 years ago

Btw Jonathan, I found one little issue during testing. Editing an album results in a exception as the db scheme is unknown to the function handling the editing. I added the db schemes but it still gave me errors. Would you mind taking a look will I work on the album/track stuff ?

Thanks!

Jon889 commented 10 years ago

Ah, I hadn't changed it from jugglingdb to sequelize. Should be fixed now.

jansmolders86 commented 10 years ago

Great! thanks! You might have seen I made a crude solution for the track view. It works without the need for a playlist. (still need to update the playbar though)

But what I want to discuss with you is how we'll handle continuing to the next song when using the track view. Any ideas since we are not using the playlist? Ideally it would just play the next track in the list regardless of album or position.

Also, the order by functionality doesn't quite work yet. When a song finishes playing, the next song will start, but although the next song is highlighted correctly in the playlist, another song is played. So of instance after song 1, song 2 is being highlighted as being active correctly, but song 4 is playing.

I think is might be because the order by is just a visual thing, the actual order of the tracks is still wrong. We either need to solve it my letting angular check the order digit. Or save the tracks in order when writing to the db.

What do you think?

Jon889 commented 10 years ago

I've changed it so that when the app downloads the albums, it sorts the tracks into order. This seems better than doing it on the server side, because if a new track is added to the database it won't be in order.

jansmolders86 commented 10 years ago

Nice, very smart solution Jonathan!

jansmolders86 commented 10 years ago

Hey Jonathan, Thanks for straightening out the headers. I want your opinion, would this effect be nice for the movies app?

http://tympanus.net/Tutorials/3DShadingWithBoxShadows/

I kind of like it but I'm not sure if it would be too much.

Jon889 commented 10 years ago

I quite like it, but it probably would be too much.. Sadly, though there are quite a few things on the other demos that looked good and could be used, like buttons and such.

jansmolders86 commented 9 years ago

Why sadly? Send me links and ill add them. If it makes the project better i dont see why not :) I like the idea behind the flipping cover. I might borrow this idea and implement it with less heavy animations

Jon889 commented 9 years ago

The comma after sadly should've been a full stop :) A less heavy animation would work great.

jansmolders86 commented 9 years ago

Haha excellent! The whole point of this project is the fact it's a hell of a lot easier to customize than for instance xbmc. The pitfall of that though is I am still looking for a default design that will work. I keep having new ideasabut not enough time to implement then across the board. Resulting in half finished sections and ideas. I feel the music app has improved though. Next up is definitely the home screen. If you have any ideas or elements you would love to see in the project, feel free to send them and I'll add then as best I can.

BTW can I conclude the serialize branch is ready to be merged into master?

Jon889 commented 9 years ago

As far as I can see it's ready for merging :)

I was thinking of separating out like the header into an angular directive, but then realised it would reduce the ability to customise it.

For the homepage I had a rough idea of pulling content out to it from the apps, for example showing the previously watched movie, or the next movie in a series. And for TV showing the next episode in the series of the last watched episode, or the latest aired/added episode. (Or even if we can detect if a user watches a show in some pattern like everyday at a certain time)

For listing tracks in the album view something like this might be nice: http://tympanus.net/Tutorials/ThumbnailGridExpandingPreview/ And for opening apps perhaps this kind of effect? http://tympanus.net/Tutorials/ExpandingOverlayEffect/

Also currently each apps loads in a new page, but if in the future we want media (audio mainly, though I guess Picture-in-Picture would be possible) to play in the background, the apps would have to load in the same page, as the media would currently stop when the new page reloads. I think Angular has built in support for this, routing.

jansmolders86 commented 9 years ago

Man I'm so happy to decided to help me with this project! I can't express that enough! You bring a much needed fresh perspective and great coding to this project and I am so grateful! :)

I love that tympanus site! I just found it yesterday but I'm already so inspired by its examples. I love your picks! They are exactly what the project needs to make it feel more mature! I also love the idea of adding info to the frontpage.

I have used angular routing at work and it's very powerful and easy to use. But I wonder how we would combine it with the current backend routing. Could we just base all the interaction with the backend on ajax calls?

Ps, You may do the honors of merging :+1:

Jon889 commented 9 years ago

I am glad to be working on it, I'm learning a lot and it's a great project! Yes, I have spent probably too long paging back through the demos on tympanus :)

I would imagine the backend would remain mostly the same, I don't really know, I will read up on angular's routing. As I understand it already there are two type of angular routing, one based on URLs and the other on states, it seems like the URL based routing should be suitable for MCJS?

I've started a new branch called netflix, showing how I imagined it could integrate with the Movies app, and then how you could have different sources. It's very rough atm, and just a suggestion/idea :)

Thanks, I shall merge it now :)

jansmolders86 commented 9 years ago

Excellent Jonathan! I impressed to see what you've done in the Netflix branch. It's crazy to see you work around the api like that! If you agree, I'll continue the redesign and start on the angular routing stuff :)

Let's close this rather long thread and start new ones for their appropriate task.