Skip to content

Commit

Permalink
added object hash feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Matheus Cesar C. - Matsukii committed Oct 25, 2019
1 parent bffad98 commit 5799332
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 1 deletion.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ A set of useful apis
* express
* js-video-url-parser
* qrcode-svg
* object-hash

## Inside but not in use

Expand All @@ -33,7 +34,21 @@ response:

* json

### see samples file or below

## SHA/MD5 hashes

```http
https://polarpod.herokuapp.com/apis/hasher?d=[data]&m=[MD5|SHA]
```

parameters

* d: data
* m: hash algorithm

responses

* json

## SVG QR Code generator

Expand Down Expand Up @@ -149,6 +164,26 @@ _for vimeo thumbails the image size '_640' is replaced by '_1920'_
}
```

## hasher

```json
succesfull (status 200)
{
"type":"sha",
"original":"test",
"hash":"8d56ea07e4ac6175807ed5f66279715d394d8885",
"success":true
}

failed (status 400)
{
"type":"sha",
"original":"test",
"hash":"",
"success":false
}
```

## Modules credits

[qrcode-svg by papnkukn](https://github.com/papnkukn/qrcode-svg)
Expand All @@ -161,6 +196,8 @@ _for vimeo thumbails the image size '_640' is replaced by '_1920'_

[metafetch by brahma-dev](https://github.com/brahma-dev/metafetch)

[object-hash by addaleax](https://github.com/puleos/object-hash)

## LICENSE

* MIT
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*
* @author Matsukii
*
* facebook embed video plugin url
* https://www.facebook.com/plugins/video.php?href=
*
* * Og tag getter
* https://polarpod.herokuapp.com/apis/ogtags?u=[url]
Expand All @@ -25,6 +27,8 @@ const path = require('path');
const cors = require('cors')
const conf = require('./src/config');

const test = require('./src/facebookVideoUrlParser');
test();

// 0ac6kh - 1abz19
const hasher = require('object-hash');
Expand Down
Binary file added other/452001751_1920.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added other/452001751_9000.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added other/Thumbs.db
Binary file not shown.
10 changes: 10 additions & 0 deletions other/fbVideoUrls.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
https://qz.com/1234502/how-to-block-facebook-all-the-urls-you-need-to-block-to-actually-stop-using-facebook/

https://www.facebook.com/felipe.abruzzesi/videos/697600310738165/?t=4
https://www.facebook.com/felipe.abruzzesi/videos/697600310738165/?t=4
https://www.fb.com/felipe.abruzzesi/videos/697600310738165/?t=4


[http] site home user vieo catg video id start time
https://www. fb.com/ felipe.abruzzesi/ videos/ 697600310738165/ ?t=4

1 change: 1 addition & 0 deletions other/vimeo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"id":76979871,"title":"The New Vimeo Player (You Know, For Videos)","description":"It may look (mostly) the same on the surface, but under the hood we totally rebuilt our player. Here\u2019s a quick rundown of some of the coolest new features:<br \/>\r\n<br \/>\r\n\u2022 Lightning fast playback<br \/>\r\n\u2022 Redesigned Share screen<br \/>\r\n\u2022 Closed caption and subtitle compatible<br \/>\r\n\u2022 HTML5 by default<br \/>\r\n\u2022 Purchase-from-player functionality for embedded Vimeo On Demand trailers<br \/>\r\n\u2022 More responsive than ever (go ahead, resize it, we dare you!!!)<br \/>\r\n<br \/>\r\nWe\u2019re really proud of these updates. So proud that we made a spiffy new page to showcase all the reasons why we have the best video player in the galaxy. Check it out here: http:\/\/vimeo.com\/player<br \/>\r\n<br \/>\r\nIn short, this is a player that even haters can love.","url":"https:\/\/vimeo.com\/76979871","upload_date":"2013-10-15 14:08:29","mobile_url":"https:\/\/vimeo.com\/76979871","thumbnail_small":"https:\/\/i.vimeocdn.com\/video\/452001751_100x75.webp","thumbnail_medium":"https:\/\/i.vimeocdn.com\/video\/452001751_200x150.webp","thumbnail_large":"https:\/\/i.vimeocdn.com\/video\/452001751_640.webp","user_id":152184,"user_name":"Vimeo Staff","user_url":"https:\/\/vimeo.com\/staff","user_portrait_small":"https:\/\/i.vimeocdn.com\/portrait\/9934446_30x30.webp","user_portrait_medium":"https:\/\/i.vimeocdn.com\/portrait\/9934446_75x75.webp","user_portrait_large":"https:\/\/i.vimeocdn.com\/portrait\/9934446_100x100.webp","user_portrait_huge":"https:\/\/i.vimeocdn.com\/portrait\/9934446_300x300.webp","duration":62,"width":1280,"height":720,"tags":"","embed_privacy":"anywhere"}]
1 change: 1 addition & 0 deletions other/vimeo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><videos><video><id>6271487</id><title>Spheres</title><description>Finally up is my own little space opera : a mesmerizing choregraphy evoking atoms, DNA, seeds, spirals, fractals, etc... inspired by Anaxagoras of Clazomenae. http://philosophy.gr/presocratics/anaxagoras.htm&lt;br /&gt; &lt;br /&gt; The first draft screened in 2008 as a backdrop for the robotic and live music performance by URBAN ORCHESTRA at the city council new year celebration meeting critical acclaim.&lt;br /&gt; &lt;br /&gt; This is the final director's cut with updated soundtrack and tighter edits to my original vision : 42000 HD frames at 50p running for 14 minutes.&lt;br /&gt; &lt;br /&gt; ***converted to 720p 25fps &amp; download enabled***</description><url>https://vimeo.com/6271487</url><upload_date>2009-08-25 17:36:46</upload_date><mobile_url>https://vimeo.com/6271487</mobile_url><thumbnail_small>https://i.vimeocdn.com/video/23566238_100x75.webp</thumbnail_small><thumbnail_medium>https://i.vimeocdn.com/video/23566238_200x150.webp</thumbnail_medium><thumbnail_large>https://i.vimeocdn.com/video/23566238_640.webp</thumbnail_large><user_id>314303</user_id><user_name>Regis Hervagault</user_name><user_url>https://vimeo.com/regishervagault</user_url><user_portrait_small>https://i.vimeocdn.com/portrait/1185115_30x30.webp</user_portrait_small><user_portrait_medium>https://i.vimeocdn.com/portrait/1185115_75x75.webp</user_portrait_medium><user_portrait_large>https://i.vimeocdn.com/portrait/1185115_100x100.webp</user_portrait_large><user_portrait_huge>https://i.vimeocdn.com/portrait/1185115_300x300.webp</user_portrait_huge><duration>840</duration><width>1280</width><height>720</height><tags>spheres, spaceballs, motion, design, psychedelic, hypnotic, morphing, choregraphy, ambient, drone, soundscape, trippy</tags><embed_privacy>anywhere</embed_privacy></video></videos>
8 changes: 8 additions & 0 deletions src/facebookVideoUrlParser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = (url = false) => {
let a = "aaa/bbb/ccc";
let reg = new RegExp('\/[a-z]{1,}\/');
console.log(reg.exec(a));



};
28 changes: 28 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = (app, dir) => {
const wordFilter = require('./word-filter');
const resMsgs = require('./responseMessages');
const conf = require('./config');
const hasher = require('object-hash');


/**
Expand Down Expand Up @@ -186,6 +187,33 @@ module.exports = (app, dir) => {
}
});

/**
* @description hash function
*
* params: d = data, m = mode (MD5 or sha1)
*
* @returns the hash from given data
*/
app.get('/apis/hasher', function(req, res, next){
let mode = req.query.m;
let dat = req.query.d;

let mdrgx = new RegExp('MD5', 'gi');
let shagx = new RegExp('sha', 'gi');
if(mode == ''){
mode = 'SHA';
}

if(mdrgx.test(mode)){
return res.status(200).json({type: mode, original: dat, hash: hasher.MD5(dat), success: true});
}
else if(shagx.test(mode)){
return res.status(200).json({type: mode, original: dat, hash: hasher.sha1(dat), success: true})
}
else{
return res.status(400).json({type: mode, original: dat, hash: '', success: false})
}

})

}

0 comments on commit 5799332

Please sign in to comment.