DoctorD1501 / JAVMovieScraper

Scrape XBMC and Kodi movie metadeta and automatically rename files for Japanese Adult Videos (JAV), American Adult DVDs, and American Adult Webcontent
GNU General Public License v2.0
752 stars 161 forks source link

Developer discussion #25

Closed ScrappingFTW closed 8 years ago

ScrappingFTW commented 9 years ago

Hi DoctorD,

I'm not really a java developer and trying to learn and need to clarify some concepts from the code.

One thing I would like to understand is why you're using both Actions and ActionListeners for the controller layer instead of choosing one of them and stick with it.

I do see the convenience of having a single set of actions and share them between menuitems and buttons. So here's my proposal: moving all actionlisteners to actions, then initialize main menu and/or buttons with these actions.

Tell me what do you think about it and I'll submit a patch in a few days.

DoctorD1501 commented 9 years ago

Hi ScrappingFTW,

I'll be the first to admit that this program is not entirely consistent in the way it was written and could use some better organization of the various classes/packages. I've been slowly trying to clean it up to make more sense and be more modular since my initial version of this program released on GitHub which had a TON of code in GUIMain.java that really should have been split up into separate modules. Even now, a good bit of code remains there that should be split up into various classes. It's been sort of a battle between adding new features quickly and trying to spend time to get the program more logically organized.

That said, to answer your question, a Action is used when you want to be able to add in some additional code to be able to set up the name of the menu item, key shortucts, icon, etc all within the same class that defines it's behavior. It's useful if the action will always be associated with the same type of component in the program, such as consistently named button that appears multiple places in the program. An ActionListener is sort of an action without having to worry about setting the way the action will look when it's used in the GUI. If you're going to call the action in several different places without using the same GUI component, it's better to use an ActionListener.

OK, with all that being said, I don't think I've used the Action / ActionListener patterns consistently. Some of this is due to just not being familiar with when I should use each class when initially writing the program and just using whatever had worked at the time, some of this is due to receiving contributed code that I've incorporated into the program that had its own style.

I think where it makes sense, it would great if you could convert some of the ActionListener classes to Actions. In theory this is moving some of the presentation logic into the controller (how a button is named being mixed with what that button does), but honestly it's probably not a big deal and seems to be the way Swing sort of expects you to design programs anyways.

I would say if you're going to take a look at refactoring the menus, just make sure you're on the latest version of the source code because I've made some modifications to this recently. I took a stab a few days ago at moving some of the menu initializations out of the GUIMain file and into a new class called GUIMainMenuBar.java. It's still kind of got all the menu's initializations (and their behaviors) in one giant block of code, but it was my first stab at trying to get some handle on cleaning up the menu code by moving it its own logical block. If you want, maybe you can create classes for each different menu item and then add them back into the JMenuBar in GUIMainMenuBar.java.

I hope that all made sense, but feel free to submit any follow up questions if you still have any.

Thanks again for your contributions!

DoctorD1501 commented 9 years ago

Oh and by the way, I've set you up as a collaborator. This will allow you to push your changes to github.

If you're not doing this already, I'd recommend integrating git into your IDE so the whole git pull/push/merge process is much easier for you and you don't need to memorize a bunch of command line options. I use eclipse for my IDE and egit to integrate git into eclipse, but if you're using something else then that will work too, I'm sure! It's a bit of pain to get git installed and learn how to use it, but it will save you time in the long run and you'll be learning something that's great to know how to use! Just let me know if you have any questions about git.

ScrappingFTW commented 9 years ago

Hi, DoctorD

That's awesome, thanks for the detailed explanation and for adding me as collaborator. I'm already using Eclipse and certainly taking a look on egit. Still getting used to the tools and git workflow so, I hope not to screw up ;)

I was familiar with the concept of Action/ActionListener from other languages but also doubtful because of the ambiguity of Action from the MVC point of view, thanks for clarifying that out.

I'm looking forward the main gui refactoring and hopefully pushing some code thereafter.

paulchenjavlist commented 9 years ago

Hi @DoctorD1501, I found this repo online while looking for a nice renamer for my huge jav library. And I must admit that this is some fine work you have done here. As a matter of fact, I've worked on something similar before but it could parse from dmm. So I'm wondering if there is anything that I could contribute to.

DoctorD1501 commented 9 years ago

Hey Geraldrotation,

If you'd like to contribute and you don't have something of your own in mind, you can just take a look at the items on the issues page. Some of the tasks on there which might be a good thing for a beginner to this code base to do would be to create a new scraper. As long as you create the scraper in SiteParsingProfile.specific package and extend SiteParsingProfile and implement SpecificProfile (similar to the other scrapers in that package), you won't even have to worry about writing any GUI code or understanding how that part works too much.

If you know a lot about Java Swing or user interface design, you can also work on improving the interface or fixing various bugs in the program with the GUI.

paulchenjavlist commented 9 years ago

@DoctorD1501 That sounds interesting. Another thing I was thinking of was to rewrite some of the core code to let them run concurrently. Right now, the scraping process can be slow when fetching from various websites. I will have a look at that.

DoctorD1501 commented 9 years ago

That might work well if you can get it to work. The JAV movie amalgamation process actually runs 5 or 6 all at once, so there are some examples of getting that to work using different threads. The code to run that part of scraping is in a different method than the regular SiteSpecificParsing scraping, so there's definitely some work to be done there in bringing it all together in one unified process. One thing you may want to watch out for when testing is getting blocked by Google for scrapers that use that to make their search results. If you make too many requests too fast, you get banned for a long period of time and if you run 10-15 requests all at once, the ban could be easily triggered.

DoctorD1501 commented 8 years ago

Closing this issue. If we want to have more discussions later, we can open a new issue.