-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Audio & Video binary extraction #341
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0e46ca7
Audio and Videao binary extraction; #306, #307.
ruebot 81d97e6
audio and video binary extraction; #306, #307
ruebot eadef02
add pdf, audio, video df tests, remove tweet cruft
ruebot 575ffbb
test tweaks
ruebot 769a7d5
Add saveMediaBytesTest (saveToDisk test)
ruebot 2bc20e8
better filename and extension extraction with FilenameUtils, add back…
ruebot f2c0a7c
Use tika-parsers artifact, classifier "shaded", from jrwiebe repo, te…
jrwiebe a88aa46
Use tika-parsers artifact, classifier "shaded", from jrwiebe repo, te…
jrwiebe f44dc33
Eliminate bytes->string->bytes conversion that was causing data loss.
jrwiebe 38aec52
Merge branch 'fix-detectmimetype' into issue-306-307
jrwiebe 910e22e
Pass binary bytes instread of string to DetectMimeTypeTika.
jrwiebe 1f7fff9
Use tika-parsers 1.22-shady from AU repo.
jrwiebe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
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
64 changes: 64 additions & 0 deletions
64
src/test/scala/io/archivesunleashed/df/ExtractAudioDetailsTest.scala
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,64 @@ | ||
/* | ||
* Archives Unleashed Toolkit (AUT): | ||
* An open-source toolkit for analyzing web archives. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.archivesunleashed | ||
|
||
import com.google.common.io.Resources | ||
import org.apache.spark.sql.SparkSession | ||
// scalastyle:off underscore.import | ||
import io.archivesunleashed.df._ | ||
import org.apache.spark.sql.functions._ | ||
// scalastyle:on underscore.import | ||
import org.apache.spark.{SparkConf, SparkContext} | ||
import org.junit.runner.RunWith | ||
import org.scalatest.junit.JUnitRunner | ||
import org.scalatest.{BeforeAndAfter, FunSuite} | ||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class ExtractAudioDetailsTest extends FunSuite with BeforeAndAfter { | ||
private val warcPath = Resources.getResource("warc/example.media.warc.gz").getPath | ||
private val master = "local[4]" | ||
private val appName = "example-df" | ||
private var sc: SparkContext = _ | ||
|
||
before { | ||
val conf = new SparkConf() | ||
.setMaster(master) | ||
.setAppName(appName) | ||
sc = new SparkContext(conf) | ||
} | ||
|
||
test("Audio DF extraction") { | ||
val df = RecordLoader.loadArchives(warcPath, sc) | ||
.extractAudioDetailsDF() | ||
|
||
val extracted = df.select("url", "filename", "extension", "mime_type", "md5") | ||
.orderBy(desc("md5")).head(1).toList | ||
assert(extracted.size == 1) | ||
assert("https://ruebot.net/files/feniz.mp3" == extracted(0)(0)) | ||
assert("feniz.mp3" == extracted(0)(1)) | ||
assert("mp3" == extracted(0)(2)) | ||
assert("audio/mpeg" == extracted(0)(3)) | ||
assert("f7e7ec84b12c294e19af1ba41732c733" == extracted(0)(4)) | ||
} | ||
|
||
after { | ||
if (sc != null) { | ||
sc.stop() | ||
} | ||
} | ||
} |
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
69 changes: 69 additions & 0 deletions
69
src/test/scala/io/archivesunleashed/df/ExtractPDFDetailsTest.scala
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,69 @@ | ||
/* | ||
* Archives Unleashed Toolkit (AUT): | ||
* An open-source toolkit for analyzing web archives. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.archivesunleashed | ||
|
||
import com.google.common.io.Resources | ||
import org.apache.spark.sql.SparkSession | ||
// scalastyle:off underscore.import | ||
import io.archivesunleashed.df._ | ||
import org.apache.spark.sql.functions._ | ||
// scalastyle:on underscore.import | ||
import org.apache.spark.{SparkConf, SparkContext} | ||
import org.junit.runner.RunWith | ||
import org.scalatest.junit.JUnitRunner | ||
import org.scalatest.{BeforeAndAfter, FunSuite} | ||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class ExtractPDFDetailsTest extends FunSuite with BeforeAndAfter { | ||
private val warcPath = Resources.getResource("warc/example.pdf.warc.gz").getPath | ||
private val master = "local[4]" | ||
private val appName = "example-df" | ||
private var sc: SparkContext = _ | ||
|
||
before { | ||
val conf = new SparkConf() | ||
.setMaster(master) | ||
.setAppName(appName) | ||
sc = new SparkContext(conf) | ||
} | ||
|
||
test("PDF DF extraction") { | ||
val df = RecordLoader.loadArchives(warcPath, sc) | ||
.extractPDFDetailsDF() | ||
|
||
val extracted = df.select("url", "filename", "extension", "mime_type", "md5") | ||
.orderBy(desc("md5")).head(2).toList | ||
assert(extracted.size == 2) | ||
assert("https://yorkspace.library.yorku.ca/xmlui/bitstream/handle/10315/36158/cost-analysis.pdf?sequence=1&isAllowed=y" == extracted(0)(0)) | ||
assert("cost-analysis.pdf" == extracted(0)(1)) | ||
assert("pdf" == extracted(0)(2)) | ||
assert("application/pdf" == extracted(0)(3)) | ||
assert("aaba59d2287afd40c996488a39bbc0dd" == extracted(0)(4)) | ||
assert("https://yorkspace.library.yorku.ca/xmlui/bitstream/handle/10315/36158/JCDL%20-%20Cost%20of%20a%20WARC%20Presentation-4.pdf?sequence=3&isAllowed=y" == extracted(1)(0)) | ||
assert("JCDL%20-%20Cost%20of%20a%20WARC%20Presentation-4.pdf" == extracted(1)(1)) | ||
assert("pdf" == extracted(1)(2)) | ||
assert("application/pdf" == extracted(1)(3)) | ||
assert("322cd5239141408c42f7441f15eed9af" == extracted(1)(4)) | ||
} | ||
|
||
after { | ||
if (sc != null) { | ||
sc.stop() | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can fix this after this is merged. We're working on sorting JitPack builds/releases now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also change the classifier to `shady'