Skip to content

Commit

Permalink
Merge pull request #1 from NETHeader/develop
Browse files Browse the repository at this point in the history
Merging develop into master
  • Loading branch information
NETHeader committed Jul 2, 2015
2 parents 0aab598 + 9969a0a commit 2f2bc5d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 34 deletions.
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

#Maven
cache
target
release.properties
pom.xml.*

#IntelliJ IDEA
.idea/
*.iml

#Eclipse
.classpath
.project
.settings
bin
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</parent>

<artifactId>scraper-aebn</artifactId>
<version>1.1</version>
<name>tinyMediaManager scraper-AEBN</name>
<description>An Adult Entertainment scraper for tinyMediaManager.</description>
<version>0.2</version>
<name>tinyMediaManager scraper-aebn</name>
<description>An Adult Entertainment scraper plugin for tinyMediaManager.</description>

<build>
<plugins>
Expand Down Expand Up @@ -60,7 +60,6 @@
</issueManagement>
<scm>
<url>https://github.com/NETHeader/${project.artifactId}</url>
<tag>HEAD</tag>
<connection>scm:git:https://github.com/NETHeader/${project.artifactId}</connection>
<developerConnection>scm:git:https://github.com/NETHeader</developerConnection>
</scm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* Implements scraping of meta data, artwork and trailers.
*
* @author NETHead <[email protected]>
* @version 0.1
* @version 0.2
* @see IMediaMetadataProvider
* @see IMediaArtworkProvider
* @see IMediaTrailerProvider
Expand All @@ -57,9 +57,8 @@
@PluginImplementation
public class AebnMetadataProvider implements IMovieMetadataProvider, IMediaArtworkProvider, IMovieTrailerProvider {
private static AebnMetadataProvider instance;
private static final String AEBNID = "AebnId";
private static MediaProviderInfo providerInfo = new MediaProviderInfo(AEBNID, "aebn.net",
"Media scraper for the Adult Entertainment Broadcast Network (AEBN)");
private static final String AEBNID = "AebnID";
private static MediaProviderInfo providerInfo = createMediaProviderInfo();
private static final Logger LOGGER = LoggerFactory.getLogger(AebnMetadataProvider.class);
private static final String BASE_DATAURL = "http://theater.aebn.net";
private static final String BASE_IMGURL = "http://pic.aebn.net";
Expand All @@ -80,6 +79,15 @@ public MediaProviderInfo getProviderInfo() {
return providerInfo;
}

private static MediaProviderInfo createMediaProviderInfo() {
MediaProviderInfo providerInfo = new MediaProviderInfo(
AEBNID,
"aebn.net",
"<html><h3>Adult Entertainment Broadcast Network</h3><br />An adult movie database. This scraper is able to scrape metadata and artwork.</html>",
AebnMetadataProvider.class.getResource("/aebn_net.png"));
return providerInfo;
}

/**
* Search for movies at aebn.net.
*
Expand Down Expand Up @@ -195,7 +203,7 @@ public MediaMetadata getMetadata(MediaScrapeOptions options) throws Exception {
LOGGER.debug("AEBN: getMetadata() {}", options);

// check if there is already meta data present in the result
if (options.getResult() != null && options.getResult().getMediaMetadata() != null) {
if ((options.getResult() != null) && (options.getResult().getMediaMetadata() != null)) {
LOGGER.debug("AEBN: return metadata from cache");
return options.getResult().getMediaMetadata();
}
Expand All @@ -205,19 +213,19 @@ public MediaMetadata getMetadata(MediaScrapeOptions options) throws Exception {
Element element = null;
Integer aebnId = 0;

// get aebnId from previous search result
// get AebnId from previous search result
if ((options.getResult() != null) && (options.getResult().getId() != null)) {
aebnId = Integer.parseInt(options.getResult().getId());
LOGGER.debug("AEBN: got aebnId({}) from previous search result", aebnId);
LOGGER.debug("AEBN: aebnId() from previous search result = {}", aebnId);
// preset some values from search result (if there is one)
// Use core.Utils.RemoveSortableName() if you want eg "Bourne Legacy, The" -> "The Bourne Legacy".
md.storeMetadata(MediaMetadata.ORIGINAL_TITLE, StrgUtils.removeCommonSortableName(options.getResult().getOriginalTitle()));
md.storeMetadata(MediaMetadata.TITLE, StrgUtils.removeCommonSortableName(options.getResult().getTitle()));
}

// or get aebnId from options
if (!isValidAebnId(aebnId)) {
LOGGER.debug("AEBN: got aebnId({}) from options", options.getId(AEBNID));
// or get AebnId from options
if (!isValidAebnId(aebnId) && (options.getId(AEBNID) != null)) {
LOGGER.debug("AEBN: aebnId() from options = {}", options.getId(AEBNID));
aebnId = Integer.parseInt(options.getId(AEBNID));
}

Expand Down
Binary file added src/main/resource/aebn_net.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@
* A test class for scraping aebn.net.
*
* @author NETHead <[email protected]>
* @version 0.1
* @version 0.2
* @see AebnMetadataProvider
*
*/
public class AebnMetadataProviderTest {

@Test
public void testSearch() {
@Test
public void testSearch() throws Exception {
try {
IMovieMetadataProvider aebn = new AebnMetadataProvider();
MediaSearchOptions options = new MediaSearchOptions(MediaType.MOVIE);

options.set(SearchParam.QUERY, "Erotic Massage Stories 5");
IMovieMetadataProvider aebn = new AebnMetadataProvider();
MediaSearchOptions options = new MediaSearchOptions(MediaType.MOVIE);

List<MediaSearchResult> results = aebn.search(options);
assertThat(results.size()).isEqualTo(60);
options.set(SearchParam.QUERY, "Erotic Massage Stories 5");
List<MediaSearchResult> results = aebn.search(options);
assertThat(results.size()).isEqualTo(60);
}
catch (Exception e) {
e.printStackTrace();
Assert.fail();
System.err.println(e.getMessage());
e.printStackTrace();
Assert.fail();
}
}
}

@Test
public void testScrape() throws Exception {
@Test
public void testScrapeData() throws Exception {
try {
IMovieMetadataProvider aebn = new AebnMetadataProvider();
MediaScrapeOptions options = new MediaScrapeOptions(MediaType.MOVIE);
Expand All @@ -52,15 +52,16 @@ public void testScrape() throws Exception {
assertThat(md.getStringValue(MediaMetadata.PRODUCTION_COMPANY)).isEqualTo("Pure Passion");
assertThat(md.getStringValue(MediaMetadata.TMDBID)).isEqualTo("");
assertThat(md.getStringValue(MediaMetadata.IMDBID)).isEqualTo("");
assertThat(md.getStringValue(MediaMetadata.RUNTIME)).isEqualTo(145);
assertThat(md.getGenres().size()).isEqualTo(8);
assertThat(md.getStringValue(MediaMetadata.RUNTIME)).isEqualTo("145");
assertThat(md.getGenres().size()).isEqualTo(7);
assertThat(md.getGenres().contains(MediaGenres.EROTIC)).isTrue();
assertThat(md.getStringValue(MediaMetadata.COLLECTION_NAME)).isEqualTo("Erotic Massage Stories");
assertThat(md.getCastMembers().size()).isEqualTo(8); // Don't forget to add actor + director!
assertThat(md.getCastMembers().size()).isEqualTo(8); // Don't forget to add actor + director to this number!
}
catch (Exception e) {
e.printStackTrace();
Assert.fail();
System.err.println(e.getMessage());
e.printStackTrace();
Assert.fail();
}
}
}
}

0 comments on commit 2f2bc5d

Please sign in to comment.