-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from ratanparai/feature/wow-scrapper
wow scrapper
- Loading branch information
Showing
13 changed files
with
1,231 additions
and
10 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
app/src/androidTest/java/com/ratanparai/moviedog/db/dao/scrapper/WowMovieZoneScrapperTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.ratanparai.moviedog.db.dao.scrapper | ||
|
||
import androidx.test.espresso.matcher.ViewMatchers.assertThat | ||
import com.ratanparai.moviedog.scrapper.WowMovieZoneScrapper | ||
import org.hamcrest.CoreMatchers.equalTo | ||
import org.jsoup.Jsoup | ||
import org.jsoup.nodes.Document | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class WowMovieZoneScrapperTest { | ||
|
||
private lateinit var searchDoc: Document | ||
private lateinit var movieDoc: Document | ||
|
||
@Before | ||
fun loadHtml() { | ||
val searchResultFile = ClassLoader.getSystemResource("wow/HarryPotterSearch_wow.data").readText() | ||
val deathlyHalosFile = ClassLoader.getSystemResource("wow/HarryPotter_Deadly_Hallows_part2.data").readText() | ||
|
||
searchDoc = Jsoup.parse(searchResultFile, "http://172.27.27.84") | ||
movieDoc = Jsoup.parse(deathlyHalosFile, "http://172.27.27.84") | ||
} | ||
|
||
@Test | ||
fun shouldGetMovieFromMovieDocument() { | ||
val scrapper = WowMovieZoneScrapper() | ||
|
||
val movie = scrapper.getMovie(movieDoc) | ||
|
||
assertThat(movie.title, equalTo("Harry Potter And The Deathly Hallows Part 2")) | ||
assertThat(movie.description, equalTo("Harry, Ron, and Hermione search for Voldemort''s remaining Horcruxes in their effort to destroy the Dark Lord as the final battle rages on at Hogwarts.")) | ||
assertThat(movie.videoUrl, equalTo("http://172.27.27.251/2TB1/1080p/2011/Harry%20Potter%20And%20The%20Deathly%20Hallows%20Part%202%20%282011%29%20%5B1080p%5D/Harry%20Potter%20And%20The%20Deathly%20Hallows%20Part%202%20%282011%29%20%5B1080p%5D.mp4")) | ||
assertThat(movie.productionYear, equalTo(2011)) | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
app/src/main/java/com/ratanparai/moviedog/db/dao/MovieUrlDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.ratanparai.moviedog.db.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.Query | ||
import com.ratanparai.moviedog.db.entity.MovieUrl | ||
|
||
@Dao | ||
interface MovieUrlDao { | ||
|
||
@Insert | ||
fun insertMovieUrl(movieUrl: MovieUrl) | ||
|
||
@Query("SELECT * FROM movieUrl WHERE movieId = :id") | ||
fun getMovieUrlsByMovieId(id: Int): List<MovieUrl> | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/com/ratanparai/moviedog/db/dao/ScrappedDao.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.ratanparai.moviedog.db.dao | ||
|
||
import androidx.room.Dao | ||
import androidx.room.Insert | ||
import androidx.room.Query | ||
import com.ratanparai.moviedog.db.entity.Scrapped | ||
|
||
@Dao | ||
interface ScrappedDao { | ||
@Query("SELECT * FROM scrapped WHERE url = :url") | ||
fun getByUrl(url: String) : Scrapped? | ||
|
||
@Insert | ||
fun insert(scrapped: Scrapped) | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/ratanparai/moviedog/db/entity/MovieUrl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.ratanparai.moviedog.db.entity | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "movieUrl") | ||
data class MovieUrl( | ||
@PrimaryKey(autoGenerate = true) @ColumnInfo(name = "id") val id: Int = 0, | ||
val movieId: Int, | ||
val movieUrl: String, | ||
val serviceName: String | ||
) |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/ratanparai/moviedog/db/entity/MovieWithMovieUrls.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.ratanparai.moviedog.db.entity | ||
|
||
import androidx.room.Embedded | ||
import androidx.room.Relation | ||
|
||
data class MovieWithMovieUrls ( | ||
@Embedded val movie: Movie, | ||
@Relation(parentColumn = "id", entityColumn = "movieId", entity = MovieUrl::class) val movieUrls : List<MovieUrl> | ||
) |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/ratanparai/moviedog/db/entity/Scrapped.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.ratanparai.moviedog.db.entity | ||
|
||
import androidx.room.ColumnInfo | ||
import androidx.room.Entity | ||
import androidx.room.PrimaryKey | ||
|
||
@Entity(tableName = "scrapped") | ||
data class Scrapped ( | ||
@PrimaryKey(autoGenerate = true) @ColumnInfo(name = "id") val id: Int = 0, | ||
val url: String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<tr><td><a href="http://172.27.27.84/movie/1354"><img style="border-radius:10px;" width="100px" src="/movie_poster/1548309132_image.jpg"></a></td><td><a href="http://172.27.27.84/movie/1354"<span style="font-size: 20px;color: white;" >Harry Potter and the Deathly Hallows Part 1</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 7.70</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/1530"><img style="border-radius:10px;" width="100px" src="/movie_poster/1548310428_image.jpg"></a></td><td><a href="http://172.27.27.84/movie/1530"<span style="font-size: 20px;color: white;" >Harry Potter And The Deathly Hallows Part 2</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 8.10</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/3963"><img style="border-radius:10px;" width="100px" src="/movie_poster/1548432022_image.jpg"></a></td><td><a href="http://172.27.27.84/movie/3963"<span style="font-size: 20px;color: white;" >Harry Potter and the Chamber of Secrets</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 7.40</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/3964"><img style="border-radius:10px;" width="100px" src="/movie_poster/1548432025_image.jpg"></a></td><td><a href="http://172.27.27.84/movie/3964"<span style="font-size: 20px;color: white;" >Harry Potter and the Deathly Hallows Part 1</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 7.70</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/3965"><img style="border-radius:10px;" width="100px" src="/movie_poster/1548432029_image.jpg"></a></td><td><a href="http://172.27.27.84/movie/3965"<span style="font-size: 20px;color: white;" >Harry Potter and the Deathly Hallows Part 2</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 8.10</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/3966"><img style="border-radius:10px;" width="100px" src="/movie_poster/1548432034_image.jpg"></a></td><td><a href="http://172.27.27.84/movie/3966"<span style="font-size: 20px;color: white;" >Harry Potter and the Goblet of Fire</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 7.70</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/3967"><img style="border-radius:10px;" width="100px" src="/default_images/default_poster.jpg"></a></td><td><a href="http://172.27.27.84/movie/3967"<span style="font-size: 20px;color: white;" >Harry Potter and the Half Blood Prince</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 0.00</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/3968"><img style="border-radius:10px;" width="100px" src="/movie_poster/1548432040_image.jpg"></a></td><td><a href="http://172.27.27.84/movie/3968"<span style="font-size: 20px;color: white;" >Harry Potter and the Order of the Phoenix</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 7.50</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/3969"><img style="border-radius:10px;" width="100px" src="/movie_poster/1548432044_image.jpg"></a></td><td><a href="http://172.27.27.84/movie/3969"<span style="font-size: 20px;color: white;" >Harry Potter and the Prisoner of Azkaban</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 7.90</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/3970"><img style="border-radius:10px;" width="100px" src="/default_images/default_poster.jpg"></a></td><td><a href="http://172.27.27.84/movie/3970"<span style="font-size: 20px;color: white;" >Harry Potter and the Sorcerers Stone</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 0.00</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/9159"><img style="border-radius:10px;" width="100px" src="/movie_poster/1548585953_image.jpg"></a></td><td><a href="http://172.27.27.84/movie/9159"<span style="font-size: 20px;color: white;" >Harry Potter and the Deathly Hallows Part 2</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 8.10</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/14092"><img style="border-radius:10px;" width="100px" src="/movie_poster/1550727987_image.jpg"></a></td><td><a href="http://172.27.27.84/movie/14092"<span style="font-size: 20px;color: white;" >Harry Potter and the Deathly Hallows Part 1</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 7.70</i></td><td width="700px"></td></tr><tr><td><a href="http://172.27.27.84/movie/14093"><img style="border-radius:10px;" width="100px" src="/movie_poster/1550727990_image.jpg"></a></td><td><a href="http://172.27.27.84/movie/14093"<span style="font-size: 20px;color: white;" >Harry Potter and the Deathly Hallows Part 2</span></a><br><span style="color:yellow">Movie</span><br><i class="fa fa-star"> 8.10</i></td><td width="700px"></td></tr> |
Oops, something went wrong.