How to extract URL to video from Website Code - java

I am in the process of making an application that streams anime from sites. However in order to do so, I need the direct link to a video for instance:
http://s1000.animepremium.tv/stream/74017.mp4
However, this site I'm currently trying to stream from animeseason.com, but I cannot find the link to the video from the code.
Here's the code:
Mp4up Player
As you can see the video seems to be encrypted, is it possible to decrypt? If so how would I achieve this?
Thanks in advance!
Edit: I already have a streaming thing set up in java that will work for any video such as the one from the first link. I just need to know how to decrypt the video link from the code above...
Edit2; I am using Java, so if there is already a solution in java please tell me

Challenge accepted if you mean the video URL is encrypted and not the video itself.
And it is not like the video URL is encrypted, it is more like "obfuscated" since the structure of the data is visible. So to de-obfuscate:
public class Q21300109 {
public static final String urlEncoded = "%{3c%-69%$66%X72%!61%F6d%N65%Z20%#6d%[61%W72%J67%#69%U6e%#68%C65%J69%V67%R68%B74%D3d%-22%[30%G22%S20%P6d%A61%M72%~67%Y69%A6e%T77%V69%*64%D74%I68%+3d%R22%[30%Z22%L20%Q73%]63%A72%+6f%X6c%C6c%G69%F6e%U67%H3d%I22%Q6e%C6f%P22%[20%S66%P72%G61%F6d%A65%H62%Y6f%V72%?64%!65%#72%+3d%E22%Y30%X22%Q20%A77%T69%Q64%+74%C68%T3d%D22%H35%?34%L30%Q22%P20%O68%*65%K69%{67%H68%R74%+3d%H22%Z33%W30%#34%Y22%K20%S73%W72%P63%C3d%F22%*68%D74%Y74%H70%A3a%!2f%~2f%E6d%]70%~34%P75%L70%B6c%#6f%D61%M64%W2e%K63%#6f%U6d%R2f%O65%C6d%G62%?65%M64%Z2d%W34%!6b%#68%!71%T66%*7a%M37%~34%{6e%?67%N6a%-6e%[2e%A68%L74%G6d%B6c%B22%J3e%O3c%Y2f%T69%D66%E72%+61%S6d%H65%E3e";
public static void main(String... args) {
String senc = urlEncoded;
int offSet = senc.indexOf('%');
StringBuilder sb = new StringBuilder();
while (offSet > -1) {
String hex = senc.substring(offSet + 2, offSet + 4);
// hex to char, see http://stackoverflow.com/a/10101779/3080094
char c = (char)Integer.parseInt(hex, 16);
sb.append(c);
offSet = senc.indexOf('%', offSet + 1);
}
System.out.println(sb.toString());
}
}
Which produces:
<iframe marginheight="0" marginwidth="0" scrolling="no"
frameborder="0" width="540" height="304"
src="http://mp4upload.com/embed-4khqfz74ngjn.html"></iframe>

Related

Convert .bib file into a new .acm file

I am trying to convert a .bib that can contains x number of article into a ACM file with said x number of ACM notation. I've written a bit of code but would like help with the rest.
The .bib is formatted this way -->
#ARTICLE{
8249726,
author={N. Khlif and A. Masmoudi and F. Kammoun and N. Masmoudi},
journal={IET Image Processing},
title={Secure chaotic dual encryption scheme for H.264/AVC video conferencing protection},
number={1},
year={2018},
volume={12},
pages={42-52},
keywords={adaptive codes;chaotic communication;cryptography;data compression;data protection;variable length codes;video coding;H.264/AVC video conferencing protection;advanced video coding protection;chaos-based crypto-compression scheme;compression ratio;context adaptive variable length coding;decision module;format compliance;inter-prediction encryption;intra-prediction encryption;piecewise linear chaotic maps;pseudorandom bit generators;secure chaotic dual encryption scheme;selective encryption approach;video compression standards},
doi={10.1049/iet-ipr.2017.0022},
ISSN={1751-9659},
month={Dec},
}
#ARTICLE{
8093611,
author={W. Wu and H. Mao and Y. Wang and J. Wang and W. Wang and C. Tian},
journal={IEEE Access},
title={CoolConferencing: Enabling Robust Peer-to-Peer Multi-Party Video Conferencing},
year={2017},
pages={25474-25486},
number={2},
volume={5},
keywords={Internet;peer-to-peer computing;teleconferencing;video communication;CoolConferencing design;MPVC approach;MPVC platform;any-view support;multirate support;optimal video transmission performance;overlay network;realistic network environments;resilient data-driven principle;robust MPVC system;robust peer-to-peer multiparty video conferencing;robust system;state-of-the-art video;Bandwidth;Delays;Internet;Peer-to-peer computing;Receivers;Robustness;Streaming media;Computer networks;peer to peer computing;streaming media},
doi={10.1109/ACCESS.2017.2768798},
ISSN={1751-9659},
month={Dec},
}
Note that the .bib file can have any number of articles, 2 in this case so the .ACM file should have 2 ACM quotation. Also the articles information doesn't have specific line order.
I can't use any library that auto convert.
Here is the code that I have as of now. This code will read each line of 1 latex file and print all the information between { }, and now I need to save each information and then create a method to return the information in ACM format.
public static void main(String[] args) {
List<String> lines = new ArrayList<>();
try {
File myFile = new File("Latex1.bib");
Scanner reader = new Scanner(myFile);
while (reader.hasNextLine()) {
Pattern pattern = Pattern.compile("=\\{([^}]*)");
Matcher matcher = pattern.matcher(reader.nextLine());
if (matcher.find()) {
System.out.println(matcher.group(1));
}
}
} catch (FileNotFoundException e) {
e.getMessage();
}
}
Could you please complete it?

Reading Binary Picture Data from exiftool?

I'm working on a .opus music library software which converts audio/video files to .opus files and tags them with metadata automatically.
Previous versions of the program have saved the album art as binary data apparently as revealed by exiftool.
The thing is that when I run the command to output data as binary using the -b option, the entire thing is in binary seemingly. I'm not sure how to get the program to parse it. I was kind of expecting an entry like Picture : 11010010101101101011....
The output looks similar to this though:
How can I parse the picture data so I can reconstruct the image for newer versions of the program? (I'm using Java8_171 on Kubuntu 18.04)
It looks like you're trying to open the raw bytes in a text editor, which will of course give you gobble-dee-gook since those raw bytes do not represent characters that can be displayed by any text editor. I can see from your output from exiftool that you are able to know the length of the image in bytes. Providing you know the beginning byte position in the file, this should make your task relatively easy with a little bit of Java code. If you can get the starting position of the image inside your file, you should be able to do something like:
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.*;
public class SaveImage {
public static void main(String[] args) throws IOException {
byte[] imageBytes;
try (RandomAccessFile binaryReader =
new RandomAccessFile("your-file.xxx", "r")) {
int dataLength = 0; // Assign this the byte length shown in your
// post instead of zero
int startPos = 0; // I assume you can find this somehow.
// If it's not at the beginning
// change it accordingly.
imageBytes = new byte[dataLength];
binaryReader.read(imageBytes, startPos, dataLength);
}
try (InputStream in = new ByteArrayInputStream(imageBytes)) {
BufferedImage bImageFromConvert = ImageIO.read(in);
ImageIO.write(bImageFromConvert,
"jpg", // or whatever file format is appropriate
new File("/path/to/your/file.jpg"));
}
}
}

reading UTF-16 produces unexpected results

I use the beaglebuddy Java library in an Android project for reading/writing ID3 tags of mp3 files. I'm having an issue with reading the text that was previously written using the same library and could not find anything related in their docs.
Assume I write the following info:
MP3 mp3 = new MP3(pathToFile);
mp3.setLeadPerformer("Jon Skeet");
mp3.setTitle("A Million Rep");
mp3.save();
Looking at the source code of the library, I see that UTF-16 encoding is explicitly set, internally it calls
protected ID3v23Frame setV23Text(String text, FrameType frameType) {
return this.setV23Text(Encoding.UTF_16, text, frameType);
}
and
protected ID3v23Frame setV23Text(Encoding encoding, String text, FrameType frameType) {
ID3v23FrameBodyTextInformation frameBody = null;
ID3v23Frame frame = this.getV23Frame(frameType);
if(frame == null) {
frame = this.addV23Frame(frameType);
}
frameBody = (ID3v23FrameBodyTextInformation)frame.getBody();
frameBody.setEncoding(encoding);
frameBody.setText(encoding == Encoding.UTF_16?Utility.getUTF16String(text):text);
return frame;
}
At a later point, I read the data and it gives me some weird Chinese characters:
mp3.getLeadPerformer(); // 䄀 䴀椀氀氀椀漀渀 刀攀瀀
mp3.getTitle(); // 䨀漀渀 匀欀攀攀琀
I took a look at the built-in Utility.getUTF16String(String) method:
public static String getUTF16String(String string) {
String text = string;
byte[] bytes = string.getBytes(Encoding.UTF_16.getCharacterSet());
if(bytes.length < 2 || bytes[0] != -2 || bytes[1] != -1) {
byte[] bytez = new byte[bytes.length + 2];
bytes[0] = -2;
bytes[1] = -1;
System.arraycopy(bytes, 0, bytez, 2, bytes.length);
text = new String(bytez, Encoding.UTF_16.getCharacterSet());
}
return text;
}
I'm not quite getting the point of setting the first 2 bytes to -2 and -1 respectively, is this a pattern stating that the string is UTF-16 encoded?
However, I tried to explicitly call this method when reading the data, that seems to be readable, but always prepends some cryptic characters at the start:
Utility.getUTF16String(mp3.getLeadPerformer()); // ��Jon Skeet
Utility.getUTF16String(mp3.getTitle()); // ��A Million Rep
Since the count of those characters seems to be constant, I created a temporary workaround by simply cutting them off.
Fields like "comments" where the author does not explicitly enforce UTF-16 when writing are read without any issues.
I'm really curious about what's going on here and appreciate any suggestions.

How to set HTTP header in Apache JClouds?

I'm using Apache JClouds to connect to my Openstack Swift installation. I managed to upload and download objects from Swift. However, I failed to see how to upload dynamic large object to Swift.
To upload dynamic large object, I need to upload all segments first, which I can do as usual. Then I need to upload a manifest object to combine them logically. The problem is to tell Swift this is a manifest object, I need to set a special header, which I don't know how to do that using JClouds api.
Here's a dynamic large object example from openstack official website.
The code I'm using:
public static void main(String[] args) throws IOException {
BlobStore blobStore = ContextBuilder.newBuilder("swift").endpoint("http://localhost:8080/auth/v1.0")
.credentials("test:test", "test").buildView(BlobStoreContext.class).getBlobStore();
blobStore.createContainerInLocation(null, "container");
ByteSource segment1 = ByteSource.wrap("foo".getBytes(Charsets.UTF_8));
Blob seg1Blob = blobStore.blobBuilder("/foo/bar/1").payload(segment1).contentLength(segment1.size()).build();
System.out.println(blobStore.putBlob("container", seg1Blob));
ByteSource segment2 = ByteSource.wrap("bar".getBytes(Charsets.UTF_8));
Blob seg2Blob = blobStore.blobBuilder("/foo/bar/2").payload(segment2).contentLength(segment2.size()).build();
System.out.println(blobStore.putBlob("container", seg2Blob));
ByteSource manifest = ByteSource.wrap("".getBytes(Charsets.UTF_8));
// TODO: set manifest header here
Blob manifestBlob = blobStore.blobBuilder("/foo/bar").payload(manifest).contentLength(manifest.size()).build();
System.out.println(blobStore.putBlob("container", manifestBlob));
Blob dloBlob = blobStore.getBlob("container", "/foo/bar");
InputStream input = dloBlob.getPayload().openStream();
while (true) {
int i = input.read();
if (i < 0) {
break;
}
System.out.print((char) i); // should print "foobar"
}
}
The "TODO" part is my problem.
Edited:
I've been pointed out that Jclouds handles large file upload automatically, which is not so useful in our case. In fact, we do not know how large the file will be or when the next segment will arrive at the time we start to upload the first segment. Our api is designed to make client able to upload their files in chunks of their own chosen size and at their own chosen time, and when done, call a 'commit' to make these chunks as a file. So this makes us want to upload the manifest on our own here.
According to #Everett Toews's answer, I've got my code correctly running:
public static void main(String[] args) throws IOException {
CommonSwiftClient swift = ContextBuilder.newBuilder("swift").endpoint("http://localhost:8080/auth/v1.0")
.credentials("test:test", "test").buildApi(CommonSwiftClient.class);
SwiftObject segment1 = swift.newSwiftObject();
segment1.getInfo().setName("foo/bar/1");
segment1.setPayload("foo");
swift.putObject("container", segment1);
SwiftObject segment2 = swift.newSwiftObject();
segment2.getInfo().setName("foo/bar/2");
segment2.setPayload("bar");
swift.putObject("container", segment2);
swift.putObjectManifest("container", "foo/bar2");
SwiftObject dlo = swift.getObject("container", "foo/bar", GetOptions.NONE);
InputStream input = dlo.getPayload().openStream();
while (true) {
int i = input.read();
if (i < 0) {
break;
}
System.out.print((char) i);
}
}
jclouds handles writing the manifest for you. Here are a couple of examples that might help you, UploadLargeObject and largeblob.MainApp.
Try using
Map<String, String> manifestMetadata = ImmutableMap.of(
"X-Object-Manifest", "<container>/<prefix>");
BlobBuilder.userMetadata(manifestMetadata)
If that doesn't work you might have to use the CommonSwiftClient like in CrossOriginResourceSharingContainer.java.

java or node.js removes one character when sending or receiving a string

I'm trying to send a string from a java (android) app to a node.js server.
But one character disappears somewhere in the middle and I can't really figure out why.
To send I use a HttpUrlConnection (conn) and send the string like this:
try {
OutputStream os = conn.getOutputStream();
os.write(json.getBytes());
os.close();
} catch (Exception e) {
e.printStackTrace();
}
Here is the base64 encoded string when sent, and string when received:
khVGUBH2kNAR5PPRy7v5dO5iz48Rc7benYARu78\/9wY=\n
khVGUBH2kNAR5PPRy7v5dO5iz48Rc7benYARu78/9wY=\n
so one backslash has be removed.
In node I use this:
exports.getString = function(req, res) {
var string = req.body.thestring;
}
which outputs the later of the two strings.
var express = require('express'),
http = require('http'),
stylus = require('stylus'),
nib = require('nib');
var app = express();
app.configure(function () {
app.use(express.logger('dev'));
//app.use(express.bodyParser());
app.use(express.json());
app.use(express.urlencoded());
app.use(app.router);
}
Any ideas of how I can get the missing character?
The missing backslash character is most probably disappearing in node.js side.
As per the chosen answer on the following question:
Two part question on JavaScript forward slash
As far as JS is concerned / and \ / are identical inside a string
So maybe a fix from Java's would solve your problem by using String's replaceAll method to replace all occurrences of \/ with \\/:
os.write(json.replaceAll("\\/", "\\\\/").getBytes());
Note that replaceAll returns the new string and doesn't change the original string.
Making the base64 encoding url safe solved my problem.

Categories

Resources