mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-18 14:22:38 +02:00
Compare commits
391 Commits
v0.2
...
2018-08-07
Author | SHA1 | Date | |
---|---|---|---|
|
de7622ebbf | ||
|
09c9d015b4 | ||
|
3a496e3b18 | ||
|
df58f5bbdb | ||
|
9d0452d11b | ||
|
f92ac49947 | ||
|
a574fa15ac | ||
|
8f9a385b4d | ||
|
53bdfa3bf0 | ||
|
53278b2eed | ||
|
5f3c55b808 | ||
|
fb79a67370 | ||
|
3c4e12ceba | ||
|
0d1923c52f | ||
|
ce896b4247 | ||
|
a4b2d88dbe | ||
|
65ec04ea98 | ||
|
afb4de318b | ||
|
43bb17f995 | ||
|
bae7a5879f | ||
|
bd760cbcee | ||
|
cd20b4476f | ||
|
d83f2f285b | ||
|
15e6d77569 | ||
|
f97d2ef254 | ||
|
91ae2a23d7 | ||
|
066ef1d7db | ||
|
4facbf32e3 | ||
|
6bd76af326 | ||
|
caa622ffec | ||
|
c4d489f018 | ||
|
6a98293fb3 | ||
|
d79630e3b8 | ||
|
1f2fe25471 | ||
|
87fc9e9156 | ||
|
c7b0c9fd31 | ||
|
fbf874cb29 | ||
|
049ee52fb5 | ||
|
3f41d0593a | ||
|
7126f5e838 | ||
|
ead7b2e8de | ||
|
0d80a19e84 | ||
|
42c699f474 | ||
|
2bc8daa101 | ||
|
bca79d3f88 | ||
|
90dc968fd1 | ||
|
da6b98851c | ||
|
71c29d4192 | ||
|
193ca87afa | ||
|
5ea79ac1fc | ||
|
937ea49271 | ||
|
95686b803c | ||
|
5087f5f79e | ||
|
4a5f190e0e | ||
|
01a2746715 | ||
|
f4a60c1777 | ||
|
1b08bce779 | ||
|
9fa74a36c6 | ||
|
7493e2b5b8 | ||
|
8e468a9ca7 | ||
|
50924b9213 | ||
|
4c5013bc82 | ||
|
7dc09db9ca | ||
|
d92da8f0f7 | ||
|
064ba456e8 | ||
|
8ac8e08abf | ||
|
c4f32c31a8 | ||
|
4369e077c2 | ||
|
1045850043 | ||
|
2d8f4dc3c5 | ||
|
779b638fb4 | ||
|
3ca59392c2 | ||
|
9b34b68180 | ||
|
79ebdc4b39 | ||
|
8770c87389 | ||
|
c1e3352218 | ||
|
00570ce1b4 | ||
|
df33dcff4e | ||
|
e60b5ab193 | ||
|
b0c7a62f74 | ||
|
57b15a089e | ||
|
4b7fbe4188 | ||
|
2390fb58b3 | ||
|
1e8d29f6ec | ||
|
644d13686c | ||
|
aa0ff1c9b1 | ||
|
539d9f1f06 | ||
|
5ece801ce7 | ||
|
4dcea6d9c9 | ||
|
d69e2521f1 | ||
|
7927d73719 | ||
|
0620f30ae0 | ||
|
795494cfce | ||
|
ba8542156c | ||
|
55f112e034 | ||
|
208fff801d | ||
|
3c9860de43 | ||
|
a16ec196c5 | ||
|
887fc7b037 | ||
|
1bd4a40f71 | ||
|
494169f959 | ||
|
178177e787 | ||
|
1cb83ccea3 | ||
|
c899399569 | ||
|
0f93370e92 | ||
|
45c3dcb636 | ||
|
ecfc220b10 | ||
|
4b3efed7ec | ||
|
bc28c5da8e | ||
|
5bd9c1611d | ||
|
6caca4946b | ||
|
ee78e7613f | ||
|
2df2623430 | ||
|
de5f850cdb | ||
|
ac6847045c | ||
|
df6da837dc | ||
|
41b7984a4e | ||
|
38c7e0272e | ||
|
29c690dbcd | ||
|
8ba817478b | ||
|
cacbe90102 | ||
|
cb91cd5d2f | ||
|
52dfa3fe76 | ||
|
29a1c7ac09 | ||
|
6eea51eeeb | ||
|
2149af0e74 | ||
|
142a647b7a | ||
|
6e916ddd35 | ||
|
159b00145d | ||
|
26ce16baa2 | ||
|
0622fe142b | ||
|
4805b52d42 | ||
|
962617086e | ||
|
4f6277b6b5 | ||
|
5aaab9eb8c | ||
|
ef402bb5c3 | ||
|
85ac9001d6 | ||
|
7939bffcdd | ||
|
bb58aa8e31 | ||
|
1d35149191 | ||
|
be03764029 | ||
|
a07874d468 | ||
|
90d7ae8776 | ||
|
93e0562353 | ||
|
4c5d547d9c | ||
|
9a3a64010f | ||
|
e59a6f4c9e | ||
|
1506e68587 | ||
|
671cba4f68 | ||
|
374eb8f4bf | ||
|
60f7a2b3e4 | ||
|
7744172c63 | ||
|
5a763aee8d | ||
|
c14b2c6905 | ||
|
0871376922 | ||
|
c5fe9a6dc0 | ||
|
fbbcd02384 | ||
|
d34987f9c1 | ||
|
9e0565c655 | ||
|
443081c90b | ||
|
03fc09e3c6 | ||
|
45323c2b2f | ||
|
67ee73782c | ||
|
2bb9a29ddc | ||
|
5cbd363597 | ||
|
aa6ded0ea4 | ||
|
3c61dc2b57 | ||
|
3e528ddccf | ||
|
cba65d6d08 | ||
|
8d418611a2 | ||
|
98b0f0f8ba | ||
|
6f66e6d9be | ||
|
8b06299bad | ||
|
5a99981827 | ||
|
e30ad3feb4 | ||
|
77657a9154 | ||
|
3059b1ea80 | ||
|
4037c34393 | ||
|
e671a2ad02 | ||
|
1ea091f215 | ||
|
87fa4ae3ac | ||
|
d7a1dca004 | ||
|
fe48340327 | ||
|
b4c6aa41a7 | ||
|
1696aee212 | ||
|
585379d47a | ||
|
2595b5d7d8 | ||
|
f858adc884 | ||
|
44e135ce1e | ||
|
9a9ce30b16 | ||
|
0e2b80d5d7 | ||
|
1b1ab6a66e | ||
|
0284e9d488 | ||
|
f91309c7e4 | ||
|
cd012e115b | ||
|
df9e3968dc | ||
|
c237eaa254 | ||
|
f757d7d1a5 | ||
|
4fb1366aaf | ||
|
8166e33e7f | ||
|
ff3b1c9eb2 | ||
|
4924769549 | ||
|
e4fa963bdf | ||
|
54e8bb2228 | ||
|
99e7e7876e | ||
|
62c190d841 | ||
|
84d2c02a09 | ||
|
fc0ae42450 | ||
|
9599f921a5 | ||
|
e125e9aba1 | ||
|
55a77c734d | ||
|
ccd8af09b9 | ||
|
f2d02a4187 | ||
|
f19d34a5a1 | ||
|
f1534c91e2 | ||
|
cbda060b86 | ||
|
f7265ca77b | ||
|
629a4c4481 | ||
|
950ae2cc05 | ||
|
873a91259f | ||
|
c7ec50373a | ||
|
c986ff9116 | ||
|
485b465a24 | ||
|
a4b9611e66 | ||
|
38b56bf23a | ||
|
6e4bc341b7 | ||
|
fa2df09b1b | ||
|
7dda088b3f | ||
|
f6f3a213ef | ||
|
1faa91ef0f | ||
|
5caca62677 | ||
|
d7ff8b9ac7 | ||
|
ab46af9719 | ||
|
06babeb644 | ||
|
341010b391 | ||
|
995d78fa5a | ||
|
781e4f1908 | ||
|
ae59b20c0c | ||
|
d81b61ccfa | ||
|
9c78362fd7 | ||
|
18c6f0126f | ||
|
d5f47efcea | ||
|
601f61f063 | ||
|
8ed4812e00 | ||
|
f38db4d79e | ||
|
88d1068406 | ||
|
627038e2fa | ||
|
5b541e380a | ||
|
c375ddd6ab | ||
|
44c3110db0 | ||
|
120e74c1b4 | ||
|
890ba69116 | ||
|
d6da2ce406 | ||
|
0eb5711a68 | ||
|
a4ef42c2e9 | ||
|
28331e7cd6 | ||
|
6eadc6ca6f | ||
|
638d173b70 | ||
|
a9535797e6 | ||
|
fc9084eb17 | ||
|
e221358ead | ||
|
2500d0df93 | ||
|
4124c707d4 | ||
|
8e84b52152 | ||
|
f3b6b264d3 | ||
|
360f9da072 | ||
|
e3b335b9ff | ||
|
9acd30a5c5 | ||
|
3276d4e3d5 | ||
|
88586381e7 | ||
|
ebe897f120 | ||
|
1a4c3f4418 | ||
|
2ac0469750 | ||
|
c0181d8d41 | ||
|
ea3073e27f | ||
|
20ea75994d | ||
|
a84c245fa0 | ||
|
b48a44c979 | ||
|
c6ce453c47 | ||
|
bd92392921 | ||
|
59025d96bc | ||
|
155c0ac6f0 | ||
|
596b9143a8 | ||
|
a2108c784f | ||
|
c803396d7e | ||
|
ac518ca297 | ||
|
1763a1518c | ||
|
2dda74dfe7 | ||
|
b1c2a69102 | ||
|
bf7ce98719 | ||
|
8b2fdb3937 | ||
|
5d41a74067 | ||
|
100f3cd56d | ||
|
8f3c56b184 | ||
|
16bdf6b204 | ||
|
cf7da1d41c | ||
|
bb8e7495d8 | ||
|
5de03d6b9f | ||
|
1d26c7f1c3 | ||
|
790bd17d41 | ||
|
1dcef02f27 | ||
|
801ea837c9 | ||
|
9124ed640e | ||
|
6d1e8af982 | ||
|
512a4f292b | ||
|
c4169f1579 | ||
|
d93d491d8e | ||
|
c44fb25845 | ||
|
761c66d813 | ||
|
ff83410534 | ||
|
d8f5aa3c79 | ||
|
23430f1c07 | ||
|
0c3e58258c | ||
|
b4f1dc35a1 | ||
|
6f24858124 | ||
|
22a7666d2b | ||
|
04b885264d | ||
|
37b5df8985 | ||
|
f16835c223 | ||
|
7ad8693b5f | ||
|
0f25684e65 | ||
|
9bf74b2715 | ||
|
d91c25cff1 | ||
|
6ddcedb53f | ||
|
a1764a9fe2 | ||
|
1028e538ab | ||
|
49cc0661ad | ||
|
3109694b1c | ||
|
aa0a84bc26 | ||
|
eb22f86f44 | ||
|
cf909ef3a1 | ||
|
94d2ebec0a | ||
|
44c7cbe2d7 | ||
|
5b4ba621ee | ||
|
9c1bedb33f | ||
|
2fd60c68b0 | ||
|
670d8f18cb | ||
|
41714b4c40 | ||
|
a4f4447c5e | ||
|
3d984e8762 | ||
|
3a6ccc4c29 | ||
|
f45405950d | ||
|
0e5cf0d14e | ||
|
9405dc6c4b | ||
|
d0c9397613 | ||
|
5ad3198d71 | ||
|
83b5bbcc37 | ||
|
f694023f7d | ||
|
61b9c3eb48 | ||
|
d4fb02b0d0 | ||
|
95b99d42a4 | ||
|
271c71d0ac | ||
|
1e0cef8f7f | ||
|
8b52b3858e | ||
|
4a1e5245b3 | ||
|
cad78be37b | ||
|
a5b0e2a24f | ||
|
4972cec951 | ||
|
f09e8e1139 | ||
|
64fa134c40 | ||
|
d9030bfb97 | ||
|
278d6a0ec2 | ||
|
8bb002c7b6 | ||
|
b4e6c0d973 | ||
|
1ef7e40ecd | ||
|
00403214ce | ||
|
9c65c7b9e1 | ||
|
877465d508 | ||
|
35415004b9 | ||
|
e908fe648b | ||
|
3f503c4356 | ||
|
f4aa3b39e8 | ||
|
c702a0e69f | ||
|
5edba3a1aa | ||
|
8d41718553 | ||
|
72f40fbd75 | ||
|
14c689e7a3 | ||
|
84bc9d2da6 | ||
|
42cbc2e889 | ||
|
3a2cb9ea1e | ||
|
4f4fb11789 | ||
|
28e813620f | ||
|
fdf98041e3 | ||
|
29e64f77aa | ||
|
4dfbc16a5b | ||
|
af572341b3 | ||
|
51e9298a2b | ||
|
6df657179f | ||
|
2ff422d312 | ||
|
1b3efce64d | ||
|
750812c512 |
8
.dockerignore
Normal file
8
.dockerignore
Normal file
@@ -0,0 +1,8 @@
|
||||
.git
|
||||
cache/*
|
||||
DEBUG
|
||||
Dockerfile
|
||||
whitelist.txt
|
||||
phpcs.xml
|
||||
CHANGELOG.md
|
||||
CONTRIBUTING.md
|
4
.gitignore
vendored
4
.gitignore
vendored
@@ -227,8 +227,12 @@ pip-log.txt
|
||||
/cache
|
||||
/whitelist.txt
|
||||
DEBUG
|
||||
config.ini.php
|
||||
|
||||
######################
|
||||
## VisualStudioCode ##
|
||||
######################
|
||||
.vscode/*
|
||||
|
||||
#Builder
|
||||
.buildconfig
|
||||
|
27
.travis.yml
27
.travis.yml
@@ -1,19 +1,32 @@
|
||||
dist: trusty
|
||||
sudo: false
|
||||
language: php
|
||||
php:
|
||||
- '5.6'
|
||||
- '7.0'
|
||||
- hhvm
|
||||
- nightly
|
||||
|
||||
install:
|
||||
- pear install PHP_CodeSniffer
|
||||
- if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then
|
||||
composer global require squizlabs/PHP_CodeSniffer;
|
||||
else
|
||||
pear channel-update pear.php.net;
|
||||
pear install PHP_CodeSniffer;
|
||||
fi
|
||||
|
||||
script:
|
||||
- phpenv rehash
|
||||
- phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p
|
||||
- if [[ $TRAVIS_PHP_VERSION == "hhvm" ]]; then
|
||||
/home/travis/.composer/vendor/bin/phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p;
|
||||
else
|
||||
phpcs . --standard=phpcs.xml --warning-severity=0 --extensions=php -p;
|
||||
fi
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
include:
|
||||
- php: 5.6
|
||||
- php: 7.0
|
||||
- php: hhvm
|
||||
- php: nightly
|
||||
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
- php: nightly
|
110
CHANGELOG.md
110
CHANGELOG.md
@@ -1,11 +1,105 @@
|
||||
rss-bridge Changelog
|
||||
===
|
||||
|
||||
Alpha 0.1
|
||||
===
|
||||
* First tagged version.
|
||||
* Includes refactoring.
|
||||
* Unstable.
|
||||
RSS-Bridge 2017-08-19
|
||||
==
|
||||
|
||||
## General changes
|
||||
* whitelist: Do case-insensitive whitelist matching
|
||||
* [FeedExpander] Fix Serialization of 'SimpleXMLElement' is not allowed
|
||||
* [FeedExpander] Remove whitespace from source content
|
||||
* [index] Add GET parameter 'q' for search queries
|
||||
- **Example**: You can now add `&q=Twitter` to load into the search field
|
||||
* [index] Check permissions for cache folder and whitelist file
|
||||
* [index] Show bridge options when loading with URL fragment
|
||||
- **Example**: You can now add `#bridge-Twitter` to load the card with all
|
||||
parameters visible
|
||||
* [style] Center search cursor and hide placeholder
|
||||
* [validation] Fix error on undefined optional numeric value
|
||||
|
||||
## Modified bridges
|
||||
* [DanbooruBridge] Allow descendant classes to override tag collection
|
||||
* [DribbbleBridge] Add dribble bridge listing last dribble popular shots (#558)
|
||||
* [FacebookBridge] Fix & in URLs
|
||||
* [GelbooruBridge] Fix bridge not getting tags correctly
|
||||
* [GoComicsBridge] Fix for page structure changes (#568)
|
||||
* [LeBonCoinBridge] Fix bridge is marked executable
|
||||
* [LWNprevBridge] Fix everchanging url
|
||||
* [YoutubeBridge] Fix error on certain keywords
|
||||
* [YoutubeBridge] Fix issues loading playlists
|
||||
|
||||
## Removed bridges
|
||||
* VineBridge
|
||||
|
||||
RSS-Bridge 2017-08-03
|
||||
==
|
||||
|
||||
## Important changes
|
||||
* RSS-Bridge now has [contribution guidelines](CONTRIBUTING.md)
|
||||
* [phpcs rules](phpcs.xml) follow the [contribution guidelines](CONTRIBUTING.md)
|
||||
|
||||
## General changes
|
||||
* Added a search bar to make searching for bridges easier
|
||||
* Added user friendly error page for when a bridge fails
|
||||
* Added caching of extraInfos (name, uri)
|
||||
* Added an indicator to warn for bridges using HTTP instead of HTTPS
|
||||
* Various bug fixes and improvements
|
||||
|
||||
## Modified bridges
|
||||
* AllocineFRBridge] Update Faux Raccord link
|
||||
* [DanbooruBridge] Fix broken URI
|
||||
* [DuckDuckGoBridge] Disable DuckDuckGo redirects so that the links returned are correct.
|
||||
* [FacebookBridge] Add option to hide posts with facebook videos
|
||||
* [FacebookBridge] Add requester languages to HTTP header
|
||||
* [FacebookBridge] Handle summary posts
|
||||
* [FacebookBridge] Replace 'novideo' with 'media_type'
|
||||
* [FilterBridge] Initial implementation of basic title permit and block
|
||||
* [FlickrTagBridge] Fix and improve bridge by using the FlickrExploreBridge approach
|
||||
* [GooglePlusPostBridge] Autofix user names
|
||||
* [GooglePlusPostBridge] Fix bridge implementation
|
||||
* [GooglePlusPostBridge] Fix content loading
|
||||
* [InstagramBridge] Add option to filter for videos and pictures
|
||||
* [LWNprevBridge] full rewrite
|
||||
* [MangareaderBridge] Fix double forward slashes
|
||||
* [NasaApodBridge] Use HTTPS instead of HTTP
|
||||
* [PinterestBridge] Fix checkbox not working
|
||||
* [PinterestBridge] Fix implementation after DOM changes
|
||||
* [RTBFBridge] Update URI
|
||||
* [SexactuBridge] Fix URI and timestamp
|
||||
* [SexactuBridge] Use most modern version of bridge api and cached pages (#504)
|
||||
* [ShanaprojectBridge] Don't throw error if timestamp is missing
|
||||
* [TwitterBridge] Add option to hide retweets
|
||||
* [TwitterBridge] Avoid empty content caused by new login policy
|
||||
* [TwitterBridge] Fix double slashes in URI
|
||||
* [TwitterBridge] Fix missing spaces
|
||||
* [TwitterBridge] Fix title includes anchors in plaintext format
|
||||
* [TwitterBridge] ignore promoted tweets
|
||||
* [TwitterBridge] Optimize returned image sizes
|
||||
* [TwitterBridge] Show quotes and pictures
|
||||
* [WebfailBridge] Properly handle gifs (DOM changed)
|
||||
* [YoutubeBridge] Improve readability of feed contents
|
||||
* [YoutubeBridge] Improve URL handling in video descriptions
|
||||
|
||||
## New bridges
|
||||
* AmazonBridge
|
||||
* DiceBridge
|
||||
* EtsyBridge
|
||||
* FB2Bridge
|
||||
* FilterBridge
|
||||
* FlickrBridge
|
||||
* GithubSearchBridge
|
||||
* GoComicsBridge
|
||||
* KATBridge
|
||||
* KernelBugTrackerBridge
|
||||
* MixCloudBridge
|
||||
* MoinMoinBridge
|
||||
* RainbowSixSiegeBridge
|
||||
* SteamBridge
|
||||
* TheTVDBBridge
|
||||
* Torrent9Bridge
|
||||
* UsbekEtRicaBridge
|
||||
* WikiLeaksBridge
|
||||
* WordPressPluginUpdateBridge
|
||||
|
||||
Alpha 0.2
|
||||
===
|
||||
@@ -161,3 +255,9 @@ Alpha 0.2
|
||||
* YandereBridge
|
||||
* YoutubeBridge
|
||||
* ZDNetBridge
|
||||
|
||||
Alpha 0.1
|
||||
===
|
||||
* First tagged version.
|
||||
* Includes refactoring.
|
||||
* Unstable.
|
47
CONTRIBUTING.md
Normal file
47
CONTRIBUTING.md
Normal file
@@ -0,0 +1,47 @@
|
||||
### Pull request policy
|
||||
Fix one issue per pull request.
|
||||
Squash commits before opening a pull request.
|
||||
Respect the coding style policy.
|
||||
Name your PR like the following :
|
||||
|
||||
* When correcting a single bridge, use `[BridgeName] Feature`.
|
||||
* When fixing a problem in a specific file, use `[FileName] Feature`.
|
||||
* When fixing a general problem, use `category : feature`.
|
||||
|
||||
Note that all pull-requests should pass the unit tests before they can be merged.
|
||||
|
||||
### Coding style
|
||||
|
||||
Use `camelCase` for variables and methods.
|
||||
Use `UPPERCASE` for constants.
|
||||
Use `PascalCase` for class names. When creating a bridge, your class and PHP file should be named `MyImplementationBridge`.
|
||||
Use tabs for indentation.
|
||||
Add an empty line at the end of your file.
|
||||
|
||||
Use `''` to encapsulate strings, including in arrays.
|
||||
Prefer lines shorter than 80 chars, no line longer than 120 chars.
|
||||
PHP constants should be in lower case (`true, false, null`...)
|
||||
|
||||
|
||||
* Add spaces between the logical operator and your expressions (not needed for the `!` operator).
|
||||
* Use `||` and `&&` instead of `or` and `and`.
|
||||
* Add space between your condition and the opening bracket/closing bracket.
|
||||
* Don't put a space between `if` and your bracket.
|
||||
* Use `elseif` instead of `else if`.
|
||||
* Add new lines in your conditions if they are containing more than one line.
|
||||
* Example :
|
||||
|
||||
```PHP
|
||||
if($a == true && $b) {
|
||||
print($a);
|
||||
} else if(!$b) {
|
||||
|
||||
$a = !$a;
|
||||
$b = $b >> $a;
|
||||
print($b);
|
||||
|
||||
} else {
|
||||
print($b);
|
||||
}
|
||||
```
|
||||
|
5
Dockerfile
Normal file
5
Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
||||
FROM ulsmith/alpine-apache-php7
|
||||
|
||||
COPY ./ /app/public/
|
||||
|
||||
RUN chown -R apache:root /app/public
|
26
README.md
26
README.md
@@ -1,29 +1,29 @@
|
||||
rss-bridge
|
||||
===
|
||||
[](UNLICENSE)
|
||||
[](UNLICENSE) [](https://github.com/rss-bridge/rss-bridge/releases/latest) [](https://travis-ci.org/RSS-Bridge/rss-bridge) [](https://hub.docker.com/r/rssbridge/rss-bridge/)
|
||||
|
||||
rss-bridge is a PHP project capable of generating ATOM feeds for websites which don't have one.
|
||||
|
||||
Supported sites/pages (main)
|
||||
===
|
||||
|
||||
* `FlickrExplore` : [Latest interesting images](http://www.flickr.com/explore) from Flickr
|
||||
* `GoogleSearch` : Most recent results from Google Search
|
||||
* `GooglePlus` : Most recent posts of user timeline
|
||||
* `Twitter` : Return keyword/hashtag search or user timeline
|
||||
* `Identi.ca` : Identica user timeline (Should be compatible with other Pump.io instances)
|
||||
* `YouTube` : YouTube user channel, playlist or search
|
||||
* `Bandcamp` : Returns last release from [bandcamp](https://bandcamp.com/) for a tag
|
||||
* `Cryptome` : Returns the most recent documents from [Cryptome.org](http://cryptome.org/)
|
||||
* `DansTonChat`: Most recent quotes from [danstonchat.com](http://danstonchat.com/)
|
||||
* `DuckDuckGo`: Most recent results from [DuckDuckGo.com](https://duckduckgo.com/)
|
||||
* `Facebook` : Returns the latest posts on a page or profile on [Facebook](https://facebook.com/)
|
||||
* `FlickrExplore` : [Latest interesting images](http://www.flickr.com/explore) from Flickr
|
||||
* `GooglePlus` : Most recent posts of user timeline
|
||||
* `GoogleSearch` : Most recent results from Google Search
|
||||
* `Identi.ca` : Identica user timeline (Should be compatible with other Pump.io instances)
|
||||
* `Instagram`: Most recent photos from an Instagram user
|
||||
* `OpenClassrooms`: Lastest tutorials from [fr.openclassrooms.com](http://fr.openclassrooms.com/)
|
||||
* `Pinterest`: Most recent photos from user or search
|
||||
* `ScmbBridge`: Newest stories from [secouchermoinsbete.fr](http://secouchermoinsbete.fr/)
|
||||
* `Wikipedia`: highlighted articles from [Wikipedia](https://wikipedia.org/) in English, German, French or Esperanto
|
||||
* `Bandcamp` : Returns last release from [bandcamp](https://bandcamp.com/) for a tag
|
||||
* `ThePirateBay` : Returns the newest indexed torrents from [The Pirate Bay](https://thepiratebay.se/) with keywords
|
||||
* `Facebook` : Returns the latest posts on a page or profile on [Facebook](https://facebook.com/)
|
||||
* `Twitter` : Return keyword/hashtag search or user timeline
|
||||
* `Wikipedia`: highlighted articles from [Wikipedia](https://wikipedia.org/) in English, German, French or Esperanto
|
||||
* `YouTube` : YouTube user channel, playlist or search
|
||||
|
||||
Plus [many other bridges](bridges/) to enable, thanks to the community
|
||||
|
||||
@@ -32,9 +32,9 @@ Output format
|
||||
Output format can take several forms:
|
||||
|
||||
* `Atom` : ATOM Feed, for use in RSS/Feed readers
|
||||
* `Mrss` : MRSS Feed, for use in RSS/Feed readers
|
||||
* `Json` : Json, for consumption by other applications.
|
||||
* `Html` : Simple html page.
|
||||
* `Json` : Json, for consumption by other applications.
|
||||
* `Mrss` : MRSS Feed, for use in RSS/Feed readers
|
||||
* `Plaintext` : raw text (php object, as returned by print_r)
|
||||
|
||||
Screenshot
|
||||
@@ -53,7 +53,7 @@ Requirements
|
||||
|
||||
* PHP 5.6, e.g. `AddHandler application/x-httpd-php56 .php` in `.htaccess`
|
||||
* `openssl` extension enabled in PHP config (`php.ini`)
|
||||
* `allow_url_fopen=1` in `php.ini`
|
||||
* `curl` extension enabled in PHP config (`php.ini`)
|
||||
|
||||
Enabling/Disabling bridges
|
||||
===
|
||||
|
@@ -1,24 +1,41 @@
|
||||
<?php
|
||||
class ABCTabsBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "kranack";
|
||||
const NAME = "ABC Tabs Bridge";
|
||||
const URI = "http://www.abc-tabs.com/";
|
||||
const DESCRIPTION = "Returns 22 newest tabs";
|
||||
const MAINTAINER = 'kranack';
|
||||
const NAME = 'ABC Tabs Bridge';
|
||||
const URI = 'https://www.abc-tabs.com/';
|
||||
const DESCRIPTION = 'Returns 22 newest tabs';
|
||||
|
||||
public function collectData(){
|
||||
$html = '';
|
||||
$html = getSimpleHTMLDOM(static::URI.'tablatures/nouveautes.html') or returnClientError('No results for this query.');
|
||||
$html = getSimpleHTMLDOM(static::URI.'tablatures/nouveautes.html')
|
||||
or returnClientError('No results for this query.');
|
||||
|
||||
$table = $html->find('table#myTable', 0)->children(1);
|
||||
|
||||
foreach ($table->find('tr') as $tab)
|
||||
{
|
||||
foreach ($table->find('tr') as $tab) {
|
||||
$item = array();
|
||||
$item['author'] = $tab->find('td', 1)->plaintext . ' - ' . $tab->find('td', 2)->plaintext;
|
||||
$item['title'] = $tab->find('td', 1)->plaintext . ' - ' . $tab->find('td', 2)->plaintext;
|
||||
$item['content'] = 'Le ' . $tab->find('td', 0)->plaintext . '<br> Par: ' . $tab->find('td', 5)->plaintext . '<br> Type: ' . $tab->find('td', 3)->plaintext;
|
||||
$item['id'] = static::URI . $tab->find('td', 2)->find('a', 0)->getAttribute('href');
|
||||
$item['uri'] = static::URI . $tab->find('td', 2)->find('a', 0)->getAttribute('href');
|
||||
$item['author'] = $tab->find('td', 1)->plaintext
|
||||
. ' - '
|
||||
. $tab->find('td', 2)->plaintext;
|
||||
|
||||
$item['title'] = $tab->find('td', 1)->plaintext
|
||||
. ' - '
|
||||
. $tab->find('td', 2)->plaintext;
|
||||
|
||||
$item['content'] = 'Le '
|
||||
. $tab->find('td', 0)->plaintext
|
||||
. '<br> Par: '
|
||||
. $tab->find('td', 5)->plaintext
|
||||
. '<br> Type: '
|
||||
. $tab->find('td', 3)->plaintext;
|
||||
|
||||
$item['id'] = static::URI
|
||||
. $tab->find('td', 2)->find('a', 0)->getAttribute('href');
|
||||
|
||||
$item['uri'] = static::URI
|
||||
. $tab->find('td', 2)->find('a', 0)->getAttribute('href');
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class AcrimedBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = "qwertygc";
|
||||
const NAME = "Acrimed Bridge";
|
||||
const URI = "http://www.acrimed.org/";
|
||||
const MAINTAINER = 'qwertygc';
|
||||
const NAME = 'Acrimed Bridge';
|
||||
const URI = 'http://www.acrimed.org/';
|
||||
const CACHE_TIMEOUT = 4800; //2hours
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
const DESCRIPTION = 'Returns the newest articles';
|
||||
|
||||
public function collectData(){
|
||||
$this->collectExpandableDatas(static::URI . 'spip.php?page=backend');
|
||||
@@ -16,7 +16,7 @@ class AcrimedBridge extends FeedExpander {
|
||||
|
||||
$articlePage = getSimpleHTMLDOM($newsItem->link);
|
||||
$article = sanitize($articlePage->find('article.article1', 0)->innertext);
|
||||
$article = defaultImageSrcTo($article, static::URI);
|
||||
$article = defaultLinkTo($article, static::URI);
|
||||
$item['content'] = $article;
|
||||
|
||||
return $item;
|
||||
|
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
class AllocineFRBridge extends BridgeAbstract {
|
||||
|
||||
|
||||
const MAINTAINER = "superbaillot.net";
|
||||
const NAME = "Allo Cine Bridge";
|
||||
const MAINTAINER = 'superbaillot.net';
|
||||
const NAME = 'Allo Cine Bridge';
|
||||
const CACHE_TIMEOUT = 25200; // 7h
|
||||
const URI = "http://www.allocine.fr/";
|
||||
const DESCRIPTION = "Bridge for allocine.fr";
|
||||
const URI = 'http://www.allocine.fr/';
|
||||
const DESCRIPTION = 'Bridge for allocine.fr';
|
||||
const PARAMETERS = array( array(
|
||||
'category' => array(
|
||||
'name' => 'category',
|
||||
@@ -23,9 +22,11 @@ class AllocineFRBridge extends BridgeAbstract{
|
||||
));
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('category'))) {
|
||||
|
||||
switch($this->getInput('category')) {
|
||||
case 'faux-raccord':
|
||||
$uri = static::URI.'video/programme-12284/saison-27129/';
|
||||
$uri = static::URI . 'video/programme-12284/saison-32180/';
|
||||
break;
|
||||
case 'top-5':
|
||||
$uri = static::URI . 'video/programme-12299/saison-29561/';
|
||||
@@ -38,7 +39,11 @@ class AllocineFRBridge extends BridgeAbstract{
|
||||
return $uri;
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('category'))) {
|
||||
return self::NAME . ' : '
|
||||
.array_search(
|
||||
$this->getInput('category'),
|
||||
@@ -46,27 +51,27 @@ class AllocineFRBridge extends BridgeAbstract{
|
||||
);
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError("Could not request ".$this->getURI()." !");
|
||||
or returnServerError('Could not request ' . $this->getURI() . ' !');
|
||||
|
||||
$category = array_search(
|
||||
$this->getInput('category'),
|
||||
self::PARAMETERS[$this->queriedContext]['category']['values']
|
||||
);
|
||||
|
||||
|
||||
foreach($html->find('figure.media-meta-fig') as $element)
|
||||
{
|
||||
foreach($html->find('.media-meta-list figure.media-meta-fig') as $element) {
|
||||
$item = array();
|
||||
|
||||
$title = $element->find('div.titlebar h3.title a', 0);
|
||||
$content = trim($element->innertext);
|
||||
$figCaption = strpos($content, $category);
|
||||
|
||||
if($figCaption !== false)
|
||||
{
|
||||
if($figCaption !== false) {
|
||||
$content = str_replace('src="/', 'src="' . static::URI, $content);
|
||||
$content = str_replace('href="/', 'href="' . static::URI, $content);
|
||||
$content = str_replace('src=\'/', 'src=\'' . static::URI, $content);
|
||||
|
94
bridges/AmazonBridge.php
Normal file
94
bridges/AmazonBridge.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
class AmazonBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'Alexis CHEMEL';
|
||||
const NAME = 'Amazon';
|
||||
const URI = 'https://www.amazon.com/';
|
||||
const CACHE_TIMEOUT = 3600; // 1h
|
||||
const DESCRIPTION = 'Returns products from Amazon search';
|
||||
|
||||
const PARAMETERS = array(array(
|
||||
'q' => array(
|
||||
'name' => 'Keyword',
|
||||
'required' => true,
|
||||
),
|
||||
'sort' => array(
|
||||
'name' => 'Sort by',
|
||||
'type' => 'list',
|
||||
'required' => false,
|
||||
'values' => array(
|
||||
'Relevance' => 'relevanceblender',
|
||||
'Price: Low to High' => 'price-asc-rank',
|
||||
'Price: High to Low' => 'price-desc-rank',
|
||||
'Average Customer Review' => 'review-rank',
|
||||
'Newest Arrivals' => 'date-desc-rank',
|
||||
),
|
||||
'defaultValue' => 'relevanceblender',
|
||||
),
|
||||
'tld' => array(
|
||||
'name' => 'Country',
|
||||
'type' => 'list',
|
||||
'required' => true,
|
||||
'values' => array(
|
||||
'Australia' => 'com.au',
|
||||
'Brazil' => 'com.br',
|
||||
'Canada' => 'ca',
|
||||
'China' => 'cn',
|
||||
'France' => 'fr',
|
||||
'Germany' => 'de',
|
||||
'India' => 'in',
|
||||
'Italy' => 'it',
|
||||
'Japan' => 'co.jp',
|
||||
'Mexico' => 'com.mx',
|
||||
'Netherlands' => 'nl',
|
||||
'Spain' => 'es',
|
||||
'United Kingdom' => 'co.uk',
|
||||
'United States' => 'com',
|
||||
),
|
||||
'defaultValue' => 'com',
|
||||
),
|
||||
));
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('tld')) && !is_null($this->getInput('q'))) {
|
||||
return 'Amazon.'.$this->getInput('tld').': '.$this->getInput('q');
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function collectData() {
|
||||
|
||||
$uri = 'https://www.amazon.'.$this->getInput('tld').'/';
|
||||
$uri .= 's/?field-keywords='.urlencode($this->getInput('q')).'&sort='.$this->getInput('sort');
|
||||
|
||||
$html = getSimpleHTMLDOM($uri)
|
||||
or returnServerError('Could not request Amazon.');
|
||||
|
||||
foreach($html->find('li.s-result-item') as $element) {
|
||||
|
||||
$item = array();
|
||||
|
||||
// Title
|
||||
$title = $element->find('h2', 0);
|
||||
|
||||
$item['title'] = html_entity_decode($title->innertext, ENT_QUOTES);
|
||||
|
||||
// Url
|
||||
$uri = $title->parent()->getAttribute('href');
|
||||
$uri = substr($uri, 0, strrpos($uri, '/'));
|
||||
|
||||
$item['uri'] = substr($uri, 0, strrpos($uri, '/'));
|
||||
|
||||
// Content
|
||||
$image = $element->find('img', 0);
|
||||
$price = $element->find('span.s-price', 0);
|
||||
$price = ($price) ? $price->innertext : '';
|
||||
|
||||
$item['content'] = '<img src="'.$image->getAttribute('src').'" /><br />'.$price;
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
187
bridges/AmazonPriceTrackerBridge.php
Normal file
187
bridges/AmazonPriceTrackerBridge.php
Normal file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
class AmazonPriceTrackerBridge extends BridgeAbstract {
|
||||
const MAINTAINER = 'captn3m0';
|
||||
const NAME = 'Amazon Price Tracker';
|
||||
const URI = 'https://www.amazon.com/';
|
||||
const CACHE_TIMEOUT = 3600; // 1h
|
||||
const DESCRIPTION = 'Tracks price for a single product on Amazon';
|
||||
|
||||
const PARAMETERS = array(
|
||||
array(
|
||||
'asin' => array(
|
||||
'name' => 'ASIN',
|
||||
'required' => true,
|
||||
'exampleValue' => 'B071GB1VMQ',
|
||||
// https://stackoverflow.com/a/12827734
|
||||
'pattern' => 'B[\dA-Z]{9}|\d{9}(X|\d)',
|
||||
),
|
||||
'tld' => array(
|
||||
'name' => 'Country',
|
||||
'type' => 'list',
|
||||
'required' => true,
|
||||
'values' => array(
|
||||
'Australia' => 'com.au',
|
||||
'Brazil' => 'com.br',
|
||||
'Canada' => 'ca',
|
||||
'China' => 'cn',
|
||||
'France' => 'fr',
|
||||
'Germany' => 'de',
|
||||
'India' => 'in',
|
||||
'Italy' => 'it',
|
||||
'Japan' => 'co.jp',
|
||||
'Mexico' => 'com.mx',
|
||||
'Netherlands' => 'nl',
|
||||
'Spain' => 'es',
|
||||
'United Kingdom' => 'co.uk',
|
||||
'United States' => 'com',
|
||||
),
|
||||
'defaultValue' => 'com',
|
||||
),
|
||||
));
|
||||
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* Generates domain name given a amazon TLD
|
||||
*/
|
||||
private function getDomainName() {
|
||||
return 'https://www.amazon.' . $this->getInput('tld');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates URI for a Amazon product page
|
||||
*/
|
||||
public function getURI() {
|
||||
if (!is_null($this->getInput('asin'))) {
|
||||
return $this->getDomainName() . '/dp/' . $this->getInput('asin') . '/';
|
||||
}
|
||||
return parent::getURI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrapes the product title from the html page
|
||||
* returns the default title if scraping fails
|
||||
*/
|
||||
private function getTitle($html) {
|
||||
$titleTag = $html->find('#productTitle', 0);
|
||||
|
||||
if (!$titleTag) {
|
||||
return $this->getDefaultTitle();
|
||||
} else {
|
||||
return trim(html_entity_decode($titleTag->innertext, ENT_QUOTES));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Title used by the feed if none could be found
|
||||
*/
|
||||
private function getDefaultTitle() {
|
||||
return 'Amazon.' . $this->getInput('tld') . ': ' . $this->getInput('asin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns name for the feed
|
||||
* Uses title (already scraped) if it has one
|
||||
*/
|
||||
public function getName() {
|
||||
if (isset($this->title)) {
|
||||
return $this->title;
|
||||
} else {
|
||||
return parent::getName();
|
||||
}
|
||||
}
|
||||
|
||||
private function parseDynamicImage($attribute) {
|
||||
$json = json_decode(html_entity_decode($attribute), true);
|
||||
|
||||
if ($json and count($json) > 0) {
|
||||
return array_keys($json)[0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a generated image tag for the product
|
||||
*/
|
||||
private function getImage($html) {
|
||||
$imageSrc = $html->find('#main-image-container img', 0);
|
||||
|
||||
if ($imageSrc) {
|
||||
$hiresImage = $imageSrc->getAttribute('data-old-hires');
|
||||
$dynamicImageAttribute = $imageSrc->getAttribute('data-a-dynamic-image');
|
||||
$image = $hiresImage ?: $this->parseDynamicImage($dynamicImageAttribute);
|
||||
}
|
||||
$image = $image ?: 'https://placekitten.com/200/300';
|
||||
|
||||
return <<<EOT
|
||||
<img width="300" style="max-width:300;max-height:300" src="$image" alt="{$this->title}" />
|
||||
EOT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return \simple_html_dom object
|
||||
* for the entire html of the product page
|
||||
*/
|
||||
private function getHtml() {
|
||||
$uri = $this->getURI();
|
||||
|
||||
return getSimpleHTMLDOM($uri) ?: returnServerError('Could not request Amazon.');
|
||||
}
|
||||
|
||||
private function scrapePriceFromMetrics($html) {
|
||||
$asinData = $html->find('#cerberus-data-metrics', 0);
|
||||
|
||||
// <div id="cerberus-data-metrics" style="display: none;"
|
||||
// data-asin="B00WTHJ5SU" data-asin-price="14.99" data-asin-shipping="0"
|
||||
// data-asin-currency-code="USD" data-substitute-count="-1" ... />
|
||||
if ($asinData) {
|
||||
return [
|
||||
'price' => $asinData->getAttribute('data-asin-price'),
|
||||
'currency' => $asinData->getAttribute('data-asin-currency-code'),
|
||||
'shipping' => $asinData->getAttribute('data-asin-shipping')
|
||||
];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function scrapePriceGeneric($html) {
|
||||
$priceDiv = $html->find('span.offer-price', 0) ?: $html->find('.a-color-price', 0);
|
||||
|
||||
preg_match('/^\s*([A-Z]{3}|£|\$)\s?([\d.,]+)\s*$/', $priceDiv->plaintext, $matches);
|
||||
|
||||
if (count($matches) === 3) {
|
||||
return [
|
||||
'price' => $matches[2],
|
||||
'currency' => $matches[1],
|
||||
'shipping' => '0'
|
||||
];
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrape method for Amazon product page
|
||||
* @return [type] [description]
|
||||
*/
|
||||
public function collectData() {
|
||||
$html = $this->getHtml();
|
||||
$this->title = $this->getTitle($html);
|
||||
$imageTag = $this->getImage($html);
|
||||
|
||||
$data = $this->scrapePriceFromMetrics($html) ?: $this->scrapePriceGeneric($html);
|
||||
|
||||
$item = array(
|
||||
'title' => $this->title,
|
||||
'uri' => $this->getURI(),
|
||||
'content' => "$imageTag<br/>Price: {$data['price']} {$data['currency']}",
|
||||
);
|
||||
|
||||
if ($data['shipping'] !== '0') {
|
||||
$item['content'] .= "<br>Shipping: {$data['shipping']} {$data['currency']}</br>";
|
||||
}
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
@@ -48,10 +48,14 @@ class AnimeUltimeBridge extends BridgeAbstract {
|
||||
//Retrieve day and build date information
|
||||
$dateString = $daySection->plaintext;
|
||||
$day = intval(substr($dateString, strpos($dateString, ' ') + 1, 2));
|
||||
$item_date = strtotime(str_pad($day, 2, '0', STR_PAD_LEFT).'-'
|
||||
.substr($requestFilter, 0, 2).'-'
|
||||
$item_date = strtotime(str_pad($day, 2, '0', STR_PAD_LEFT)
|
||||
. '-'
|
||||
. substr($requestFilter, 0, 2)
|
||||
. '-'
|
||||
. substr($requestFilter, 2, 4));
|
||||
$release = $daySection->next_sibling()->next_sibling()->first_child(); //<h3>day</h3><br /><table><tr> <-- useful data in table rows
|
||||
|
||||
//<h3>day</h3><br /><table><tr> <-- useful data in table rows
|
||||
$release = $daySection->next_sibling()->next_sibling()->first_child();
|
||||
|
||||
//Process each release of that day, ignoring first table row: contains table headers
|
||||
while(!is_null($release = $release->next_sibling())) {
|
||||
@@ -61,19 +65,27 @@ class AnimeUltimeBridge extends BridgeAbstract {
|
||||
$item_link_element = $release->find('td', 0)->find('a', 0);
|
||||
$item_uri = self::URI . $item_link_element->href;
|
||||
$item_name = html_entity_decode($item_link_element->plaintext);
|
||||
$item_episode = html_entity_decode(str_pad($release->find('td', 1)->plaintext, 2, '0', STR_PAD_LEFT));
|
||||
$item_episode = html_entity_decode(
|
||||
str_pad(
|
||||
$release->find('td', 1)->plaintext,
|
||||
2,
|
||||
'0',
|
||||
STR_PAD_LEFT
|
||||
)
|
||||
);
|
||||
|
||||
$item_fansub = $release->find('td', 2)->plaintext;
|
||||
$item_type = $release->find('td', 4)->plaintext;
|
||||
|
||||
if(!empty($item_uri)) {
|
||||
|
||||
//Retrieve description from description page and convert relative image src info absolute image src
|
||||
// Retrieve description from description page and
|
||||
// convert relative image src info absolute image src
|
||||
$html_item = getContents($item_uri)
|
||||
or returnServerError('Could not request Anime-Ultime: ' . $item_uri);
|
||||
$item_description = substr(
|
||||
$html_item,
|
||||
strpos($html_item, 'class="principal_contain" align="center">')
|
||||
+ 41
|
||||
strpos($html_item, 'class="principal_contain" align="center">') + 41
|
||||
);
|
||||
$item_description = substr($item_description,
|
||||
0,
|
||||
@@ -108,6 +120,7 @@ class AnimeUltimeBridge extends BridgeAbstract {
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
if(!is_null($this->getInput('type'))) {
|
||||
$typeFilter = array_search(
|
||||
$this->getInput('type'),
|
||||
self::PARAMETERS[$this->queriedContext]['type']['values']
|
||||
@@ -116,4 +129,7 @@ class AnimeUltimeBridge extends BridgeAbstract {
|
||||
return 'Latest ' . $typeFilter . ' - Anime-Ultime Bridge';
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,27 +1,30 @@
|
||||
<?php
|
||||
class Arte7Bridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Arte +7";
|
||||
const URI = "http://www.arte.tv/";
|
||||
const MAINTAINER = 'mitsukarenai';
|
||||
const NAME = 'Arte +7';
|
||||
const URI = 'https://www.arte.tv/';
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = "Returns newest videos from ARTE +7";
|
||||
const DESCRIPTION = 'Returns newest videos from ARTE +7';
|
||||
|
||||
const API_TOKEN = 'Nzc1Yjc1ZjJkYjk1NWFhN2I2MWEwMmRlMzAzNjI5NmU3NWU3ODg4ODJjOWMxNTMxYzEzZGRjYjg2ZGE4MmIwOA';
|
||||
|
||||
const PARAMETERS = array(
|
||||
'Catégorie (Français)' => array(
|
||||
'catfr' => array(
|
||||
'type' => 'list',
|
||||
'name' => 'Catégorie',
|
||||
'values' => array(
|
||||
'Toutes les vidéos (français)'=>'toutes-les-videos',
|
||||
'Actu & société'=>'actu-société',
|
||||
'Séries & fiction'=>'séries-fiction',
|
||||
'Cinéma'=>'cinéma',
|
||||
'Arts & spectacles classiques'=>'arts-spectacles-classiques',
|
||||
'Culture pop'=>'culture-pop',
|
||||
'Découverte'=>'découverte',
|
||||
'Histoire'=>'histoire',
|
||||
'Junior'=>'junior'
|
||||
|
||||
'Toutes les vidéos (français)' => null,
|
||||
'Actu & société' => 'ACT',
|
||||
'Séries & fiction' => 'SER',
|
||||
'Cinéma' => 'CIN',
|
||||
'Arts & spectacles classiques' => 'ARS',
|
||||
'Culture pop' => 'CPO',
|
||||
'Découverte' => 'DEC',
|
||||
'Histoire' => 'HIST',
|
||||
'Science' => 'SCI',
|
||||
'Autre' => 'AUT'
|
||||
)
|
||||
)
|
||||
),
|
||||
@@ -30,22 +33,22 @@
|
||||
'type' => 'list',
|
||||
'name' => 'Catégorie',
|
||||
'values' => array(
|
||||
'Alle Videos (deutsch)'=>'alle-videos',
|
||||
'Aktuelles & Gesellschaft'=>'aktuelles-gesellschaft',
|
||||
'Fernsehfilme & Serien'=>'fernsehfilme-serien',
|
||||
'Kino'=>'kino',
|
||||
'Kunst & Kultur'=>'kunst-kultur',
|
||||
'Popkultur & Alternativ'=>'popkultur-alternativ',
|
||||
'Entdeckung'=>'entdeckung',
|
||||
'Geschichte'=>'geschichte',
|
||||
'Junior'=>'junior'
|
||||
'Alle Videos (deutsch)' => null,
|
||||
'Aktuelles & Gesellschaft' => 'ACT',
|
||||
'Fernsehfilme & Serien' => 'SER',
|
||||
'Kino' => 'CIN',
|
||||
'Kunst & Kultur' => 'ARS',
|
||||
'Popkultur & Alternativ' => 'CPO',
|
||||
'Entdeckung' => 'DEC',
|
||||
'Geschichte' => 'HIST',
|
||||
'Wissenschaft' => 'SCI',
|
||||
'Sonstiges' => 'AUT'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function collectData(){
|
||||
|
||||
switch($this->queriedContext) {
|
||||
case 'Catégorie (Français)':
|
||||
$category = $this->getInput('catfr');
|
||||
@@ -57,33 +60,39 @@
|
||||
break;
|
||||
}
|
||||
|
||||
$url = self::URI.'guide/'.$lang.'/plus7/'.$category;
|
||||
$input = getContents($url) or die('Could not request ARTE.');
|
||||
if(strpos($input, 'categoryVideoSet') !== FALSE){
|
||||
$input = explode('categoryVideoSet="', $input);
|
||||
$input = explode('}}', $input[1]);
|
||||
$input = $input[0].'}}';
|
||||
}else{
|
||||
$input = explode('videoSet="', $input);
|
||||
$input = explode('}]}', $input[1]);
|
||||
$input = $input[0].'}]}';
|
||||
}
|
||||
$url = 'https://api.arte.tv/api/opa/v3/videos?sort=-lastModified&limit=10&language='
|
||||
. $lang
|
||||
. ($category != null ? '&category.code=' . $category : '');
|
||||
|
||||
$input_json = json_decode(html_entity_decode($input, ENT_QUOTES), TRUE);
|
||||
$header = array(
|
||||
'Authorization: Bearer ' . self::API_TOKEN
|
||||
);
|
||||
|
||||
$input = getContents($url, $header) or die('Could not request ARTE.');
|
||||
$input_json = json_decode($input, true);
|
||||
|
||||
foreach($input_json['videos'] as $element) {
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = str_replace("autoplay=1", "", $element['url']);
|
||||
$item['uri'] = $element['url'];
|
||||
$item['id'] = $element['id'];
|
||||
$hack_broadcast_time = $element['rights_end'];
|
||||
$hack_broadcast_time = strtok($hack_broadcast_time, 'T');
|
||||
$hack_broadcast_time = strtok('T');
|
||||
$item['timestamp'] = strtotime($element['scheduled_on'].'T'.$hack_broadcast_time);
|
||||
|
||||
$item['timestamp'] = strtotime($element['videoRightsBegin']);
|
||||
$item['title'] = $element['title'];
|
||||
|
||||
if(!empty($element['subtitle']))
|
||||
$item['title'] = $element['title'] . ' | ' . $element['subtitle'];
|
||||
$item['duration'] = round((int)$element['duration']/60);
|
||||
$item['content'] = $element['teaser'].'<br><br>'.$item['duration'].'min<br><a href="'.$item['uri'].'"><img src="' . $element['thumbnail_url'] . '" /></a>';
|
||||
|
||||
$item['duration'] = round((int)$element['durationSeconds'] / 60);
|
||||
$item['content'] = $element['teaserText']
|
||||
. '<br><br>'
|
||||
. $item['duration']
|
||||
. 'min<br><a href="'
|
||||
. $item['uri']
|
||||
. '"><img src="'
|
||||
. $element['mainImage']['url']
|
||||
. '" /></a>';
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class AskfmBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "az5he6ch";
|
||||
const NAME = "Ask.fm Answers";
|
||||
const URI = "http://ask.fm/";
|
||||
const MAINTAINER = 'az5he6ch';
|
||||
const NAME = 'Ask.fm Answers';
|
||||
const URI = 'https://ask.fm/';
|
||||
const CACHE_TIMEOUT = 300; //5 min
|
||||
const DESCRIPTION = "Returns answers from an Ask.fm user";
|
||||
const DESCRIPTION = 'Returns answers from an Ask.fm user';
|
||||
const PARAMETERS = array(
|
||||
'Ask.fm username' => array(
|
||||
'u' => array(
|
||||
@@ -23,17 +23,31 @@ class AskfmBridge extends BridgeAbstract{
|
||||
$item = array();
|
||||
$item['uri'] = self::URI . $element->find('a.streamItemsAge', 0)->href;
|
||||
$question = trim($element->find('h1.streamItemContent-question', 0)->innertext);
|
||||
$item['title'] = trim(htmlspecialchars_decode($element->find('h1.streamItemContent-question',0)->plaintext, ENT_QUOTES));
|
||||
|
||||
$item['title'] = trim(
|
||||
htmlspecialchars_decode($element->find('h1.streamItemContent-question', 0)->plaintext,
|
||||
ENT_QUOTES
|
||||
)
|
||||
);
|
||||
|
||||
$answer = trim($element->find('p.streamItemContent-answer', 0)->innertext);
|
||||
#$item['update'] = $element->find('a.streamitemsage',0)->data-hint; // Doesn't work, DOM parser doesn't seem to like data-hint, dunno why
|
||||
$visual = $element->find('div.streamItemContent-visual',0)->innertext; // This probably should be cleaned up, especially for YouTube embeds
|
||||
|
||||
// Doesn't work, DOM parser doesn't seem to like data-hint, dunno why
|
||||
#$item['update'] = $element->find('a.streamitemsage',0)->data-hint;
|
||||
|
||||
// This probably should be cleaned up, especially for YouTube embeds
|
||||
$visual = $element->find('div.streamItemContent-visual', 0)->innertext;
|
||||
//Fix tracking links, also doesn't work
|
||||
foreach($element->find('a') as $link) {
|
||||
if(strpos($link->href, 'l.ask.fm') !== false) {
|
||||
#$link->href = str_replace('#_=_', '', get_headers($link->href, 1)['Location']); // Too slow
|
||||
|
||||
// Too slow
|
||||
#$link->href = str_replace('#_=_', '', get_headers($link->href, 1)['Location']);
|
||||
|
||||
$link->href = $link->plaintext;
|
||||
}
|
||||
}
|
||||
|
||||
$content = '<p>' . $question . '</p><p>' . $answer . '</p><p>' . $visual . '</p>';
|
||||
// Fix relative links without breaking // scheme used by YouTube stuff
|
||||
$content = preg_replace('#href="\/(?!\/)#', 'href="' . self::URI, $content);
|
||||
@@ -43,10 +57,18 @@ class AskfmBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('u'))) {
|
||||
return self::NAME . ' : ' . $this->getInput('u');
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('u'))) {
|
||||
return self::URI . urlencode($this->getInput('u')) . '/answers/more?page=0';
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class BandcampBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "sebsauvage";
|
||||
const NAME = "Bandcamp Tag";
|
||||
const URI = "http://bandcamp.com/";
|
||||
const MAINTAINER = 'sebsauvage';
|
||||
const NAME = 'Bandcamp Tag';
|
||||
const URI = 'https://bandcamp.com/';
|
||||
const CACHE_TIMEOUT = 600; // 10min
|
||||
const DESCRIPTION = "New bandcamp release by tag";
|
||||
const DESCRIPTION = 'New bandcamp release by tag';
|
||||
const PARAMETERS = array( array(
|
||||
'tag' => array(
|
||||
'name' => 'tag',
|
||||
@@ -24,9 +24,21 @@ class BandcampBridge extends BridgeAbstract{
|
||||
$uri = rtrim($uri, "')");
|
||||
|
||||
$item = array();
|
||||
$item['author'] = $release->find('div.itemsubtext',0)->plaintext . ' - ' . $release->find('div.itemtext',0)->plaintext;
|
||||
$item['title'] = $release->find('div.itemsubtext',0)->plaintext . ' - ' . $release->find('div.itemtext',0)->plaintext;
|
||||
$item['content'] = '<img src="' . $uri . '"/><br/>' . $release->find('div.itemsubtext',0)->plaintext . ' - ' . $release->find('div.itemtext',0)->plaintext;
|
||||
$item['author'] = $release->find('div.itemsubtext', 0)->plaintext
|
||||
. ' - '
|
||||
. $release->find('div.itemtext', 0)->plaintext;
|
||||
|
||||
$item['title'] = $release->find('div.itemsubtext', 0)->plaintext
|
||||
. ' - '
|
||||
. $release->find('div.itemtext', 0)->plaintext;
|
||||
|
||||
$item['content'] = '<img src="'
|
||||
. $uri
|
||||
. '"/><br/>'
|
||||
. $release->find('div.itemsubtext', 0)->plaintext
|
||||
. ' - '
|
||||
. $release->find('div.itemtext', 0)->plaintext;
|
||||
|
||||
$item['id'] = $release->find('a', 0)->getAttribute('href');
|
||||
$item['uri'] = $release->find('a', 0)->getAttribute('href');
|
||||
$this->items[] = $item;
|
||||
@@ -34,10 +46,18 @@ class BandcampBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('tag'))) {
|
||||
return self::URI . 'tag/' . urlencode($this->getInput('tag')) . '?sort_field=date';
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return $this->getInput('tag') .' - '.'Bandcamp Tag';
|
||||
if(!is_null($this->getInput('tag'))) {
|
||||
return $this->getInput('tag') . ' - Bandcamp Tag';
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
}
|
||||
|
@@ -1,19 +1,22 @@
|
||||
<?php
|
||||
class BastaBridge extends BridgeAbstract {
|
||||
const MAINTAINER = "qwertygc";
|
||||
const NAME = "Bastamag Bridge";
|
||||
const URI = "http://www.bastamag.net/";
|
||||
|
||||
const MAINTAINER = 'qwertygc';
|
||||
const NAME = 'Bastamag Bridge';
|
||||
const URI = 'http://www.bastamag.net/';
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
const DESCRIPTION = 'Returns the newest articles.';
|
||||
|
||||
public function collectData(){
|
||||
// Replaces all relative image URLs by absolute URLs. Relative URLs always start with 'local/'!
|
||||
function ReplaceImageUrl($content){
|
||||
// Replaces all relative image URLs by absolute URLs.
|
||||
// Relative URLs always start with 'local/'!
|
||||
function replaceImageUrl($content){
|
||||
return preg_replace('/src=["\']{1}([^"\']+)/ims', 'src=\'' . self::URI . '$1\'', $content);
|
||||
}
|
||||
|
||||
$html = getSimpleHTMLDOM(self::URI . 'spip.php?page=backend')
|
||||
or returnServerError('Could not request Bastamag.');
|
||||
|
||||
$limit = 0;
|
||||
|
||||
foreach($html->find('item') as $element) {
|
||||
@@ -22,11 +25,10 @@ class BastaBridge extends BridgeAbstract{
|
||||
$item['title'] = $element->find('title', 0)->innertext;
|
||||
$item['uri'] = $element->find('guid', 0)->plaintext;
|
||||
$item['timestamp'] = strtotime($element->find('dc:date', 0)->plaintext);
|
||||
$item['content'] = ReplaceImageUrl(getSimpleHTMLDOM($item['uri'])->find('div.texte', 0)->innertext);
|
||||
$item['content'] = replaceImageUrl(getSimpleHTMLDOM($item['uri'])->find('div.texte', 0)->innertext);
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -1,12 +1,11 @@
|
||||
<?php
|
||||
class BlaguesDeMerdeBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "superbaillot.net";
|
||||
const NAME = "Blagues De Merde";
|
||||
const URI = "http://www.blaguesdemerde.fr/";
|
||||
const MAINTAINER = 'superbaillot.net';
|
||||
const NAME = 'Blagues De Merde';
|
||||
const URI = 'http://www.blaguesdemerde.fr/';
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = "Blagues De Merde";
|
||||
|
||||
const DESCRIPTION = 'Blagues De Merde';
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
@@ -15,19 +14,18 @@ class BlaguesDeMerdeBridge extends BridgeAbstract{
|
||||
foreach($html->find('article.joke_contener') as $element) {
|
||||
$item = array();
|
||||
$temp = $element->find('a');
|
||||
if(isset($temp[2]))
|
||||
{
|
||||
|
||||
if(isset($temp[2])) {
|
||||
$item['content'] = trim($element->find('div.joke_text_contener', 0)->innertext);
|
||||
$uri = $temp[2]->href;
|
||||
$item['uri'] = $uri;
|
||||
$item['title'] = substr($uri, (strrpos($uri, "/") + 1));
|
||||
$date = $element->find("li.bdm_date",0)->innertext;
|
||||
$item['title'] = substr($uri, (strrpos($uri, '/') + 1));
|
||||
$date = $element->find('li.bdm_date', 0)->innertext;
|
||||
$time = mktime(0, 0, 0, substr($date, 3, 2), substr($date, 0, 2), substr($date, 6, 4));
|
||||
$item['timestamp'] = $time;
|
||||
$item['author'] = $element->find("li.bdm_pseudo",0)->innertext;;
|
||||
$item['author'] = $element->find('li.bdm_pseudo', 0)->innertext;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
65
bridges/BloombergBridge.php
Normal file
65
bridges/BloombergBridge.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
class BloombergBridge extends BridgeAbstract
|
||||
{
|
||||
const NAME = 'Bloomberg';
|
||||
const URI = 'https://www.bloomberg.com/';
|
||||
const DESCRIPTION = 'Trending stories from Bloomberg';
|
||||
const MAINTAINER = 'mdemoss';
|
||||
|
||||
const PARAMETERS = array(
|
||||
'Trending Stories' => array(),
|
||||
'From Search' => array(
|
||||
'q' => array(
|
||||
'name' => 'Keyword',
|
||||
'required' => true
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function getName()
|
||||
{
|
||||
switch($this->queriedContext) {
|
||||
case 'Trending Stories':
|
||||
return self::NAME . ' Trending Stories';
|
||||
case 'From Search':
|
||||
if (!is_null($this->getInput('q'))) {
|
||||
return self::NAME . ' Search : ' . $this->getInput('q');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
switch($this->queriedContext) {
|
||||
case 'Trending Stories': // Get list of top new <article>s from the front page.
|
||||
$html = getSimpleHTMLDOMCached($this->getURI(), 300);
|
||||
$stories = $html->find('ul.top-news-v3__stories article.top-news-v3-story');
|
||||
break;
|
||||
case 'From Search': // Get list of <article> elements from search.
|
||||
$html = getSimpleHTMLDOMCached(
|
||||
$this->getURI() .
|
||||
'search?sort=time:desc&page=1&query=' .
|
||||
urlencode($this->getInput('q')), 300
|
||||
);
|
||||
$stories = $html->find('div.search-result-items article.search-result-story');
|
||||
break;
|
||||
}
|
||||
foreach ($stories as $element) {
|
||||
$item['uri'] = $element->find('h1 a', 0)->href;
|
||||
if (preg_match('#^https://#i', $item['uri']) !== 1) {
|
||||
$item['uri'] = $this->getURI() . $item['uri'];
|
||||
}
|
||||
$articleHtml = getSimpleHTMLDOMCached($item['uri']);
|
||||
if (!$articleHtml) {
|
||||
continue;
|
||||
}
|
||||
$item['title'] = $element->find('h1 a', 0)->plaintext;
|
||||
$item['timestamp'] = strtotime($articleHtml->find('meta[name=iso-8601-publish-date],meta[name=date]', 0)->content);
|
||||
$item['content'] = $articleHtml->find('meta[name=description]', 0)->content;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,18 +3,19 @@ require_once('GelbooruBridge.php');
|
||||
|
||||
class BooruprojectBridge extends GelbooruBridge {
|
||||
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Booruproject";
|
||||
const URI = "http://booru.org/";
|
||||
const DESCRIPTION = "Returns images from given page of booruproject";
|
||||
|
||||
const MAINTAINER = 'mitsukarenai';
|
||||
const NAME = 'Booruproject';
|
||||
const URI = 'http://booru.org/';
|
||||
const DESCRIPTION = 'Returns images from given page of booruproject';
|
||||
const PARAMETERS = array(
|
||||
'global' => array(
|
||||
'p' => array(
|
||||
'name' => 'page',
|
||||
'type' => 'number'
|
||||
),
|
||||
't'=>array('name'=>'tags')
|
||||
't' => array(
|
||||
'name' => 'tags'
|
||||
)
|
||||
),
|
||||
'Booru subdomain (subdomain.booru.org)' => array(
|
||||
'i' => array(
|
||||
@@ -27,10 +28,18 @@ class BooruprojectBridge extends GelbooruBridge{
|
||||
const PIDBYPAGE = 20;
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('i'))) {
|
||||
return 'http://' . $this->getInput('i') . '.booru.org/';
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('i'))) {
|
||||
return static::NAME . ' ' . $this->getInput('i');
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
class CADBridge extends FeedExpander {
|
||||
const MAINTAINER = "nyutag";
|
||||
const NAME = "CAD Bridge";
|
||||
const URI = "http://www.cad-comic.com/";
|
||||
const MAINTAINER = 'nyutag';
|
||||
const NAME = 'CAD Bridge';
|
||||
const URI = 'http://www.cad-comic.com/';
|
||||
const CACHE_TIMEOUT = 7200; //2h
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
const DESCRIPTION = 'Returns the newest articles.';
|
||||
|
||||
public function collectData(){
|
||||
$this->collectExpandableDatas('http://cdn2.cad-comic.com/rss.xml', 10);
|
||||
@@ -12,25 +12,25 @@ class CADBridge extends FeedExpander {
|
||||
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
$item['content'] = $this->CADExtractContent($item['uri']);
|
||||
$item['content'] = $this->extractCADContent($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function CADExtractContent($url) {
|
||||
private function extractCADContent($url) {
|
||||
$html3 = getSimpleHTMLDOMCached($url);
|
||||
|
||||
// The request might fail due to missing https support or wrong URL
|
||||
if($html3 == false)
|
||||
return 'Daily comic not released yet';
|
||||
|
||||
$htmlpart = explode("/", $url);
|
||||
$htmlpart = explode('/', $url);
|
||||
|
||||
switch ($htmlpart[3]) {
|
||||
case 'cad':
|
||||
preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/", $html3, $url2);
|
||||
preg_match_all('/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/', $html3, $url2);
|
||||
break;
|
||||
case 'sillies':
|
||||
preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/sillies-\S*gif/", $html3, $url2);
|
||||
preg_match_all('/http:\/\/cdn2\.cad-comic\.com\/comics\/sillies-\S*gif/', $html3, $url2);
|
||||
break;
|
||||
default:
|
||||
return 'Daily comic not released yet';
|
||||
@@ -43,4 +43,3 @@ class CADBridge extends FeedExpander {
|
||||
return '<img src="' . $img . '"/>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -5,36 +5,43 @@ class CNETBridge extends BridgeAbstract {
|
||||
const NAME = 'CNET News';
|
||||
const URI = 'http://www.cnet.com/';
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = 'Returns the newest articles. <br /> You may specify a topic found in some section URLs, else all topics are selected.';
|
||||
const DESCRIPTION = 'Returns the newest articles. <br /> You may specify a
|
||||
topic found in some section URLs, else all topics are selected.';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'topic'=>array('name'=>'Topic name')
|
||||
'topic' => array(
|
||||
'name' => 'Topic name'
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
|
||||
function ExtractFromDelimiters($string, $start, $end) {
|
||||
function extractFromDelimiters($string, $start, $end){
|
||||
if(strpos($string, $start) !== false) {
|
||||
$section_retrieved = substr($string, strpos($string, $start) + strlen($start));
|
||||
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
|
||||
return $section_retrieved;
|
||||
} return false;
|
||||
}
|
||||
|
||||
function StripWithDelimiters($string, $start, $end) {
|
||||
return false;
|
||||
}
|
||||
|
||||
function stripWithDelimiters($string, $start, $end){
|
||||
while(strpos($string, $start) !== false) {
|
||||
$section_to_remove = substr($string, strpos($string, $start));
|
||||
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
|
||||
$string = str_replace($section_to_remove, '', $string);
|
||||
} return $string;
|
||||
}
|
||||
|
||||
function CleanArticle($article_html) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
function cleanArticle($article_html){
|
||||
$article_html = '<p>' . substr($article_html, strpos($article_html, '<p>') + 3);
|
||||
$article_html = StripWithDelimiters($article_html, '<span class="credit">', '</span>');
|
||||
$article_html = StripWithDelimiters($article_html, '<script', '</script>');
|
||||
$article_html = StripWithDelimiters($article_html, '<div class="shortcode related-links', '</div>');
|
||||
$article_html = StripWithDelimiters($article_html, '<a class="clickToEnlarge">', '</a>');
|
||||
$article_html = stripWithDelimiters($article_html, '<span class="credit">', '</span>');
|
||||
$article_html = stripWithDelimiters($article_html, '<script', '</script>');
|
||||
$article_html = stripWithDelimiters($article_html, '<div class="shortcode related-links', '</div>');
|
||||
$article_html = stripWithDelimiters($article_html, '<a class="clickToEnlarge">', '</a>');
|
||||
return $article_html;
|
||||
}
|
||||
|
||||
@@ -44,17 +51,23 @@ class CNETBridge extends BridgeAbstract {
|
||||
|
||||
foreach($html->find('div.assetBody') as $element) {
|
||||
if($limit < 8) {
|
||||
|
||||
$article_title = trim($element->find('h2', 0)->plaintext);
|
||||
$article_uri = self::URI . ($element->find('a', 0)->href);
|
||||
$article_timestamp = strtotime($element->find('time.assetTime', 0)->plaintext);
|
||||
$article_author = trim($element->find('a[rel=author]', 0)->plaintext);
|
||||
|
||||
if(!empty($article_title) && !empty($article_uri) && strpos($article_uri, '/news/') !== false) {
|
||||
|
||||
$article_html = getSimpleHTMLDOM($article_uri) or returnServerError('Could not request CNET: '.$article_uri);
|
||||
|
||||
$article_content = trim(CleanArticle(ExtractFromDelimiters($article_html, '<div class="articleContent', '<footer>')));
|
||||
$article_html = getSimpleHTMLDOM($article_uri)
|
||||
or returnServerError('Could not request CNET: ' . $article_uri);
|
||||
$article_content = trim(
|
||||
cleanArticle(
|
||||
extractFromDelimiters(
|
||||
$article_html,
|
||||
'<div class="articleContent',
|
||||
'<footer>'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = $article_uri;
|
||||
@@ -70,7 +83,11 @@ class CNETBridge extends BridgeAbstract {
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('topic'))) {
|
||||
$topic = $this->getInput('topic');
|
||||
return 'CNET News Bridge' . (empty($topic) ? '' : ' - ' . $topic);
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
class CastorusBridge extends BridgeAbstract {
|
||||
const MAINTAINER = "logmanoriginal";
|
||||
const NAME = "Castorus Bridge";
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const NAME = 'Castorus Bridge';
|
||||
const URI = 'http://www.castorus.com';
|
||||
const CACHE_TIMEOUT = 600; // 10min
|
||||
const DESCRIPTION = "Returns the latest changes";
|
||||
const DESCRIPTION = 'Returns the latest changes';
|
||||
|
||||
const PARAMETERS = array(
|
||||
'Get latest changes' => array(),
|
||||
@@ -28,8 +28,8 @@ class CastorusBridge extends BridgeAbstract {
|
||||
)
|
||||
);
|
||||
|
||||
// Extracts the tile from an actitiy
|
||||
private function ExtractActivityTitle($activity){
|
||||
// Extracts the title from an actitiy
|
||||
private function extractActivityTitle($activity){
|
||||
$title = $activity->find('a', 0);
|
||||
|
||||
if(!$title)
|
||||
@@ -39,7 +39,7 @@ class CastorusBridge extends BridgeAbstract {
|
||||
}
|
||||
|
||||
// Extracts the url from an actitiy
|
||||
private function ExtractActivityUrl($activity){
|
||||
private function extractActivityUrl($activity){
|
||||
$url = $activity->find('a', 0);
|
||||
|
||||
if(!$url)
|
||||
@@ -49,7 +49,7 @@ class CastorusBridge extends BridgeAbstract {
|
||||
}
|
||||
|
||||
// Extracts the time from an activity
|
||||
private function ExtractActivityTime($activity){
|
||||
private function extractActivityTime($activity){
|
||||
// Unfortunately the time is part of the parent node,
|
||||
// so we have to clear all child nodes first
|
||||
$nodes = $activity->find('*');
|
||||
@@ -65,7 +65,7 @@ class CastorusBridge extends BridgeAbstract {
|
||||
}
|
||||
|
||||
// Extracts the price change
|
||||
private function ExtractActivityPrice($activity){
|
||||
private function extractActivityPrice($activity){
|
||||
$price = $activity->find('span', 1);
|
||||
|
||||
if(!$price)
|
||||
@@ -91,17 +91,24 @@ class CastorusBridge extends BridgeAbstract {
|
||||
foreach($activities as $activity) {
|
||||
$item = array();
|
||||
|
||||
$item['title'] = $this->ExtractActivityTitle($activity);
|
||||
$item['uri'] = $this->ExtractActivityUrl($activity);
|
||||
$item['timestamp'] = $this->ExtractActivityTime($activity);
|
||||
$item['content'] = '<a href="' . $item['uri'] . '">' . $item['title'] . '</a><br><p>'
|
||||
. $this->ExtractActivityPrice($activity) . '</p>';
|
||||
$item['title'] = $this->extractActivityTitle($activity);
|
||||
$item['uri'] = $this->extractActivityUrl($activity);
|
||||
$item['timestamp'] = $this->extractActivityTime($activity);
|
||||
$item['content'] = '<a href="'
|
||||
. $item['uri']
|
||||
. '">'
|
||||
. $item['title']
|
||||
. '</a><br><p>'
|
||||
. $this->extractActivityPrice($activity)
|
||||
. '</p>';
|
||||
|
||||
if(isset($zip_filter) && !(substr($item['title'], 0, strlen($zip_filter)) === $zip_filter)){
|
||||
if(isset($zip_filter)
|
||||
&& !(substr($item['title'], 0, strlen($zip_filter)) === $zip_filter)) {
|
||||
continue; // Skip this item
|
||||
}
|
||||
|
||||
if(isset($city_filter) && !(substr($item['title'], strpos($item['title'], ' ') + 1, strlen($city_filter)) === $city_filter)){
|
||||
if(isset($city_filter)
|
||||
&& !(substr($item['title'], strpos($item['title'], ' ') + 1, strlen($city_filter)) === $city_filter)) {
|
||||
continue; // Skip this item
|
||||
}
|
||||
|
||||
|
25
bridges/ChristianDailyReporterBridge.php
Normal file
25
bridges/ChristianDailyReporterBridge.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
class ChristianDailyReporterBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'rogerdc';
|
||||
const NAME = 'Christian Daily Reporter Unofficial RSS';
|
||||
const URI = 'https://www.christiandailyreporter.com/';
|
||||
const DESCRIPTION = 'The Unofficial Christian Daily Reporter RSS';
|
||||
// const CACHE_TIMEOUT = 86400; // 1 day
|
||||
|
||||
|
||||
public function collectData() {
|
||||
$uri = 'https://www.christiandailyreporter.com/';
|
||||
|
||||
$html = getSimpleHTMLDOM($uri)
|
||||
or returnServerError('Could not request Christian Daily Reporter.');
|
||||
foreach($html->find('div.top p a,div.column p a') as $element) {
|
||||
$item = array();
|
||||
// Title
|
||||
$item['title'] = $element->innertext;
|
||||
// URL
|
||||
$item['uri'] = $element->href;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class CollegeDeFranceBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "pit-fgfjiudghdf";
|
||||
const NAME = "CollegeDeFrance";
|
||||
const URI = "http://www.college-de-france.fr/";
|
||||
const MAINTAINER = 'pit-fgfjiudghdf';
|
||||
const NAME = 'CollegeDeFrance';
|
||||
const URI = 'http://www.college-de-france.fr/';
|
||||
const CACHE_TIMEOUT = 10800; // 3h
|
||||
const DESCRIPTION = "Returns the latest audio and video from CollegeDeFrance";
|
||||
const DESCRIPTION = 'Returns the latest audio and video from CollegeDeFrance';
|
||||
|
||||
public function collectData(){
|
||||
$months = array(
|
||||
@@ -22,34 +22,44 @@ class CollegeDeFranceBridge extends BridgeAbstract{
|
||||
'11' => 'nov.',
|
||||
'12' => 'déc.'
|
||||
);
|
||||
|
||||
// The "API" used by the site returns a list of partial HTML in this form
|
||||
/* <li>
|
||||
* <a href="/site/thomas-romer/guestlecturer-2016-04-15-14h30.htm" data-target="after">
|
||||
* <span class="date"><span class="list-icon list-icon-video"></span><span class="list-icon list-icon-audio"></span>15 avr. 2016</span>
|
||||
* <span class="date"><span class="list-icon list-icon-video"></span>
|
||||
* <span class="list-icon list-icon-audio"></span>15 avr. 2016</span>
|
||||
* <span class="lecturer">Christopher Hays</span>
|
||||
* <span class='title'>Imagery of Divine Suckling in the Hebrew Bible and the Ancient Near East</span>
|
||||
* </a>
|
||||
* </li>
|
||||
*/
|
||||
$html = getSimpleHTMLDOM(self::URI.'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all')
|
||||
$html = getSimpleHTMLDOM(self::URI
|
||||
. 'components/search-audiovideo.jsp?fulltext=&siteid=1156951719600&lang=FR&type=all')
|
||||
or returnServerError('Could not request CollegeDeFrance.');
|
||||
|
||||
foreach($html->find('a[data-target]') as $element) {
|
||||
$item = array();
|
||||
$item['title'] = $element->find('.title', 0)->plaintext;
|
||||
|
||||
// Most relative URLs contains an hour in addition to the date, so let's use it
|
||||
// <a href="/site/yann-lecun/course-2016-04-08-11h00.htm" data-target="after">
|
||||
//
|
||||
// Sometimes there's an __1, perhaps it signifies an update "/site/patrick-boucheron/seminar-2016-05-03-18h00__1.htm"
|
||||
// Sometimes there's an __1, perhaps it signifies an update
|
||||
// "/site/patrick-boucheron/seminar-2016-05-03-18h00__1.htm"
|
||||
//
|
||||
// But unfortunately some don't have any hours info
|
||||
// <a href="/site/institut-physique/The-Mysteries-of-Decoherence-Sebastien-Gleyzes-[Video-3-35].htm" data-target="after">
|
||||
// <a href="/site/institut-physique/
|
||||
// The-Mysteries-of-Decoherence-Sebastien-Gleyzes-[Video-3-35].htm" data-target="after">
|
||||
$timezone = new DateTimeZone('Europe/Paris');
|
||||
// strpos($element->href, '201') will break in 2020 but it'll probably break prior to then due to site changes anyway
|
||||
|
||||
// strpos($element->href, '201') will break in 2020 but it'll
|
||||
// probably break prior to then due to site changes anyway
|
||||
$d = DateTime::createFromFormat(
|
||||
'!Y-m-d-H\hi',
|
||||
substr($element->href, strpos($element->href, '201'), 16),
|
||||
$timezone
|
||||
);
|
||||
|
||||
if(!$d) {
|
||||
$d = DateTime::createFromFormat(
|
||||
'!d m Y',
|
||||
@@ -61,8 +71,12 @@ class CollegeDeFranceBridge extends BridgeAbstract{
|
||||
$timezone
|
||||
);
|
||||
}
|
||||
|
||||
$item['timestamp'] = $d->format('U');
|
||||
$item['content'] = $element->find('.lecturer', 0)->innertext . ' - ' . $element->find('.title', 0)->innertext;
|
||||
$item['content'] = $element->find('.lecturer', 0)->innertext
|
||||
. ' - '
|
||||
. $element->find('.title', 0)->innertext;
|
||||
|
||||
$item['uri'] = self::URI . $element->href;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
class CommonDreamsBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = "nyutag";
|
||||
const NAME = "CommonDreams Bridge";
|
||||
const URI = "http://www.commondreams.org/";
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
const MAINTAINER = 'nyutag';
|
||||
const NAME = 'CommonDreams Bridge';
|
||||
const URI = 'http://www.commondreams.org/';
|
||||
const DESCRIPTION = 'Returns the newest articles.';
|
||||
|
||||
public function collectData(){
|
||||
$this->collectExpandableDatas('http://www.commondreams.org/rss.xml', 10);
|
||||
@@ -12,11 +12,11 @@ class CommonDreamsBridge extends FeedExpander {
|
||||
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
$item['content'] = $this->CommonDreamsExtractContent($item['uri']);
|
||||
$item['content'] = $this->extractContent($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function CommonDreamsExtractContent($url) {
|
||||
private function extractContent($url){
|
||||
$html3 = getSimpleHTMLDOMCached($url);
|
||||
$text = $html3->find('div[class=field--type-text-with-summary]', 0)->innertext;
|
||||
$html3->clear();
|
||||
|
93
bridges/ContainerLinuxReleasesBridge.php
Normal file
93
bridges/ContainerLinuxReleasesBridge.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
class ContainerLinuxReleasesBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'captn3m0';
|
||||
const NAME = 'Core OS Container Linux Releases Bridge';
|
||||
const URI = 'https://coreos.com/releases/';
|
||||
const DESCRIPTION = 'Returns the releases notes for Container Linux';
|
||||
|
||||
const STABLE = 'stable';
|
||||
const BETA = 'beta';
|
||||
const ALPHA = 'alpha';
|
||||
|
||||
const PARAMETERS = [
|
||||
[
|
||||
'channel' => [
|
||||
'name' => 'Release Channel',
|
||||
'type' => 'list',
|
||||
'required' => true,
|
||||
'defaultValue' => self::STABLE,
|
||||
'values' => [
|
||||
'Stable' => self::STABLE,
|
||||
'Beta' => self::BETA,
|
||||
'Alpha' => self::ALPHA,
|
||||
],
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
public function getReleaseFeed($jsonUrl) {
|
||||
$json = getContents($jsonUrl)
|
||||
or returnServerError('Could not request Core OS Website.');
|
||||
return json_decode($json, true);
|
||||
}
|
||||
|
||||
public function collectData() {
|
||||
$data = $this->getReleaseFeed($this->getJsonUri());
|
||||
|
||||
foreach ($data as $releaseVersion => $release) {
|
||||
$item = [];
|
||||
|
||||
$item['uri'] = "https://coreos.com/releases/#$releaseVersion";
|
||||
$item['title'] = $releaseVersion;
|
||||
|
||||
$content = $release['release_notes'];
|
||||
$content .= <<<EOT
|
||||
|
||||
Major Software:
|
||||
* Kernel: {$release['major_software']['kernel'][0]}
|
||||
* Docker: {$release['major_software']['docker'][0]}
|
||||
* etcd: {$release['major_software']['etcd'][0]}
|
||||
EOT;
|
||||
$item['timestamp'] = strtotime($release['release_date']);
|
||||
|
||||
// Based on https://gist.github.com/jbroadway/2836900
|
||||
// Links
|
||||
$regex = '/\[([^\[]+)\]\(([^\)]+)\)/';
|
||||
$replacement = '<a href=\'\2\'>\1</a>';
|
||||
$item['content'] = preg_replace($regex, $replacement, $content);
|
||||
|
||||
// Headings
|
||||
$regex = '/^(.*)\:\s?$/m';
|
||||
$replacement = '<h3>\1</h3>';
|
||||
$item['content'] = preg_replace($regex, $replacement, $item['content']);
|
||||
|
||||
// Lists
|
||||
$regex = '/\n\s*[\*|\-](.*)/';
|
||||
$item['content'] = preg_replace_callback ($regex, function($regs) {
|
||||
$item = $regs[1];
|
||||
return sprintf ('<ul><li>%s</li></ul>', trim ($item));
|
||||
}, $item['content']);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function getJsonUri() {
|
||||
$channel = $this->getInput('channel');
|
||||
|
||||
return "https://coreos.com/releases/releases-$channel.json";
|
||||
}
|
||||
|
||||
public function getURI() {
|
||||
return self::URI;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('channel'))) {
|
||||
return 'Container Linux Releases: ' . $this->getInput('channel') . ' Channel';
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
}
|
@@ -1,35 +1,31 @@
|
||||
<?php
|
||||
class CopieDoubleBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "superbaillot.net";
|
||||
const NAME = "CopieDouble";
|
||||
const URI = "http://www.copie-double.com/";
|
||||
const MAINTAINER = 'superbaillot.net';
|
||||
const NAME = 'CopieDouble';
|
||||
const URI = 'http://www.copie-double.com/';
|
||||
const CACHE_TIMEOUT = 14400; // 4h
|
||||
const DESCRIPTION = "CopieDouble";
|
||||
const DESCRIPTION = 'CopieDouble';
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request CopieDouble.');
|
||||
|
||||
$table = $html->find('table table', 2);
|
||||
|
||||
foreach($table->find('tr') as $element)
|
||||
{
|
||||
foreach($table->find('tr') as $element) {
|
||||
$td = $element->find('td', 0);
|
||||
if($td->class == "couleur_1")
|
||||
{
|
||||
$item = array();
|
||||
|
||||
if($td->class === 'couleur_1') {
|
||||
$item = array();
|
||||
$title = $td->innertext;
|
||||
$pos = strpos($title, "<a");
|
||||
$pos = strpos($title, '<a');
|
||||
$title = substr($title, 0, $pos);
|
||||
$item['title'] = $title;
|
||||
}
|
||||
elseif(strpos($element->innertext, "/images/suivant.gif") === false)
|
||||
{
|
||||
$a=$element->find("a", 0);
|
||||
} elseif(strpos($element->innertext, '/images/suivant.gif') === false) {
|
||||
$a = $element->find('a', 0);
|
||||
$item['uri'] = self::URI . $a->href;
|
||||
|
||||
$content = str_replace('src="/', 'src="/'.self::URI,$element->find("td", 0)->innertext);
|
||||
$content = str_replace('src="/', 'src="/' . self::URI, $element->find('td', 0)->innertext);
|
||||
$content = str_replace('href="/', 'href="' . self::URI, $content);
|
||||
$item['content'] = $content;
|
||||
$this->items[] = $item;
|
||||
|
@@ -1,42 +1,40 @@
|
||||
<?php
|
||||
class CourrierInternationalBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "teromene";
|
||||
const NAME = "Courrier International Bridge";
|
||||
const URI = "http://CourrierInternational.com/";
|
||||
const MAINTAINER = 'teromene';
|
||||
const NAME = 'Courrier International Bridge';
|
||||
const URI = 'http://CourrierInternational.com/';
|
||||
const CACHE_TIMEOUT = 300; // 5 min
|
||||
const DESCRIPTION = "Courrier International bridge";
|
||||
const DESCRIPTION = 'Courrier International bridge';
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Error.');
|
||||
|
||||
$element = $html->find("article");
|
||||
|
||||
$element = $html->find('article');
|
||||
$article_count = 1;
|
||||
|
||||
foreach($element as $article) {
|
||||
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = $article->parent->getAttribute("href");
|
||||
$item['uri'] = $article->parent->getAttribute('href');
|
||||
|
||||
if(strpos($item['uri'], "http") === FALSE) {
|
||||
if(strpos($item['uri'], 'http') === false) {
|
||||
$item['uri'] = self::URI . $item['uri'];
|
||||
}
|
||||
|
||||
$page = getSimpleHTMLDOMCached($item['uri']);
|
||||
|
||||
$content = $page->find('.article-text', 0);
|
||||
|
||||
if(!$content) {
|
||||
$content = $page->find('.depeche-text', 0);
|
||||
}
|
||||
|
||||
$item['content'] = sanitize($content);
|
||||
$item['title'] = strip_tags($article->find(".title",0));
|
||||
$item['title'] = strip_tags($article->find('.title', 0));
|
||||
|
||||
$dateTime = date_parse($page->find("time",0));
|
||||
$dateTime = date_parse($page->find('time', 0));
|
||||
|
||||
$item['timestamp'] = mktime(
|
||||
$dateTime['hour'],
|
||||
@@ -49,13 +47,9 @@ class CourrierInternationalBridge extends BridgeAbstract{
|
||||
|
||||
$this->items[] = $item;
|
||||
$article_count ++;
|
||||
if($article_count > 5) break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($article_count > 5)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -1,53 +0,0 @@
|
||||
<?php
|
||||
class CpasbienBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "lagaisse";
|
||||
const NAME = "Cpasbien Bridge";
|
||||
const URI = "http://www.cpasbien.io";
|
||||
const CACHE_TIMEOUT = 86400; // 24h
|
||||
const DESCRIPTION = "Returns latest torrents from a request query";
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'q'=>array(
|
||||
'name'=>'Search',
|
||||
'required'=>true,
|
||||
'title'=>'Type your search'
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$request = str_replace(" ","-",trim($this->getInput('q')));
|
||||
$html = getSimpleHTMLDOM(self::URI.'/recherche/'.urlencode($request).'.html')
|
||||
or returnServerError('No results for this query.');
|
||||
|
||||
foreach ($html->find('#gauche',0)->find('div') as $episode) {
|
||||
if ($episode->getAttribute('class')=='ligne0' ||
|
||||
$episode->getAttribute('class')=='ligne1')
|
||||
{
|
||||
$htmlepisode=getSimpleHTMLDOMCached($episode->find('a', 0)->getAttribute('href'));
|
||||
|
||||
$item = array();
|
||||
$item['author'] = $episode->find('a', 0)->text();
|
||||
$item['title'] = $episode->find('a', 0)->text();
|
||||
$textefiche=$htmlepisode->find('#textefiche', 0)->find('p',1);
|
||||
if (isset($textefiche)) {
|
||||
$item['content'] = $textefiche->text();
|
||||
} else {
|
||||
$p=$htmlepisode->find('#textefiche',0)->find('p');
|
||||
if(!empty($p)){
|
||||
$item['content'] = $htmlepisode->find('#textefiche', 0)->find('p',0)->text();
|
||||
}
|
||||
}
|
||||
|
||||
$item['id'] = $episode->find('a', 0)->getAttribute('href');
|
||||
$item['uri'] = self::URI . $htmlepisode->find('#telecharger',0)->getAttribute('href');
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getName(){
|
||||
return $this->getInput('q').' : '.self::NAME;
|
||||
}
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class CryptomeBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "BoboTiG";
|
||||
const NAME = "Cryptome";
|
||||
const URI = "https://cryptome.org/";
|
||||
const MAINTAINER = 'BoboTiG';
|
||||
const NAME = 'Cryptome';
|
||||
const URI = 'https://cryptome.org/';
|
||||
const CACHE_TIMEOUT = 21600; //6h
|
||||
const DESCRIPTION = "Returns the N most recent documents.";
|
||||
const DESCRIPTION = 'Returns the N most recent documents.';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'n' => array(
|
||||
@@ -19,18 +19,24 @@ class CryptomeBridge extends BridgeAbstract{
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request Cryptome.');
|
||||
|
||||
$number = $this->getInput('n');
|
||||
if (!empty($number)) { /* number of documents */
|
||||
|
||||
/* number of documents */
|
||||
if(!empty($number)) {
|
||||
$num = min($number, 20);
|
||||
}
|
||||
|
||||
|
||||
foreach($html->find('pre') as $element) {
|
||||
for($i = 0; $i < $num; ++$i) {
|
||||
$item = array();
|
||||
$item['uri'] = self::URI . substr($element->find('a', $i)->href, 20);
|
||||
$item['title'] = substr($element->find('b', $i)->plaintext, 22);
|
||||
$item['content'] = preg_replace('#http://cryptome.org/#', self::URI, $element->find('b', $i)->innertext);
|
||||
$item['content'] = preg_replace(
|
||||
'#http://cryptome.org/#',
|
||||
self::URI,
|
||||
$element->find('b', $i)->innertext
|
||||
);
|
||||
$this->items[] = $item;
|
||||
}
|
||||
break;
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class DailymotionBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Dailymotion Bridge";
|
||||
const URI = "https://www.dailymotion.com/";
|
||||
const MAINTAINER = 'mitsukarenai';
|
||||
const NAME = 'Dailymotion Bridge';
|
||||
const URI = 'https://www.dailymotion.com/';
|
||||
const CACHE_TIMEOUT = 10800; // 3h
|
||||
const DESCRIPTION = "Returns the 5 newest videos by username/playlist or search";
|
||||
const DESCRIPTION = 'Returns the 5 newest videos by username/playlist or search';
|
||||
|
||||
const PARAMETERS = array (
|
||||
'By username' => array(
|
||||
@@ -14,14 +14,12 @@ class DailymotionBridge extends BridgeAbstract{
|
||||
'required' => true
|
||||
)
|
||||
),
|
||||
|
||||
'By playlist id' => array(
|
||||
'p' => array(
|
||||
'name' => 'playlist id',
|
||||
'required' => true
|
||||
)
|
||||
),
|
||||
|
||||
'From search results' => array(
|
||||
's' => array(
|
||||
'name' => 'Search keyword',
|
||||
@@ -34,7 +32,7 @@ class DailymotionBridge extends BridgeAbstract{
|
||||
)
|
||||
);
|
||||
|
||||
function getMetadata($id) {
|
||||
protected function getMetadata($id){
|
||||
$metadata = array();
|
||||
$html2 = getSimpleHTMLDOM(self::URI . 'video/' . $id);
|
||||
if(!$html2) {
|
||||
@@ -42,7 +40,9 @@ class DailymotionBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
$metadata['title'] = $html2->find('meta[property=og:title]', 0)->getAttribute('content');
|
||||
$metadata['timestamp'] = strtotime($html2->find('meta[property=video:release_date]', 0)->getAttribute('content') );
|
||||
$metadata['timestamp'] = strtotime(
|
||||
$html2->find('meta[property=video:release_date]', 0)->getAttribute('content')
|
||||
);
|
||||
$metadata['thumbnailUri'] = $html2->find('meta[property=og:image]', 0)->getAttribute('content');
|
||||
$metadata['uri'] = $html2->find('meta[property=og:url]', 0)->getAttribute('content');
|
||||
return $metadata;
|
||||
@@ -67,7 +67,17 @@ class DailymotionBridge extends BridgeAbstract{
|
||||
$item['uri'] = $metadata['uri'];
|
||||
$item['title'] = $metadata['title'];
|
||||
$item['timestamp'] = $metadata['timestamp'];
|
||||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $metadata['thumbnailUri'] . '" /></a><br><a href="' . $item['uri'] . '">' . $item['title'] . '</a>';
|
||||
|
||||
$item['content'] = '<a href="'
|
||||
. $item['uri']
|
||||
. '"><img src="'
|
||||
. $metadata['thumbnailUri']
|
||||
. '" /></a><br><a href="'
|
||||
. $item['uri']
|
||||
. '">'
|
||||
. $item['title']
|
||||
. '</a>';
|
||||
|
||||
$this->items[] = $item;
|
||||
$count++;
|
||||
}
|
||||
@@ -85,6 +95,7 @@ class DailymotionBridge extends BridgeAbstract{
|
||||
case 'From search results':
|
||||
$specific = $this->getInput('s');
|
||||
break;
|
||||
default: return parent::getName();
|
||||
}
|
||||
|
||||
return $specific . ' : Dailymotion Bridge';
|
||||
@@ -94,20 +105,18 @@ class DailymotionBridge extends BridgeAbstract{
|
||||
$uri = self::URI;
|
||||
switch($this->queriedContext) {
|
||||
case 'By username':
|
||||
$uri.='user/'
|
||||
.urlencode($this->getInput('u')).'/1';
|
||||
$uri .= 'user/' . urlencode($this->getInput('u')) . '/1';
|
||||
break;
|
||||
case 'By playlist id':
|
||||
$uri.='playlist/'
|
||||
.urlencode(strtok($this->getInput('p'), '_'));
|
||||
$uri .= 'playlist/' . urlencode(strtok($this->getInput('p'), '_'));
|
||||
break;
|
||||
case 'From search results':
|
||||
$uri.='search/'
|
||||
.urlencode($this->getInput('s'));
|
||||
$uri .= 'search/' . urlencode($this->getInput('s'));
|
||||
if($this->getInput('pa')) {
|
||||
$uri .= '/' . $this->getInput('pa');
|
||||
}
|
||||
break;
|
||||
default: return parent::getURI();
|
||||
}
|
||||
return $uri;
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class DanbooruBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Danbooru";
|
||||
const URI = "http://donmai.us/";
|
||||
const MAINTAINER = 'mitsukarenai';
|
||||
const NAME = 'Danbooru';
|
||||
const URI = 'http://donmai.us/';
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = "Returns images from given page";
|
||||
const DESCRIPTION = 'Returns images from given page';
|
||||
|
||||
const PARAMETERS = array(
|
||||
'global' => array(
|
||||
@@ -14,29 +14,45 @@ class DanbooruBridge extends BridgeAbstract{
|
||||
'defaultValue' => 1,
|
||||
'type' => 'number'
|
||||
),
|
||||
't'=>array('name'=>'tags')
|
||||
't' => array(
|
||||
'name' => 'tags'
|
||||
)
|
||||
),
|
||||
0 => array()
|
||||
);
|
||||
|
||||
const PATHTODATA = 'article';
|
||||
const IDATTRIBUTE = 'data-id';
|
||||
const TAGATTRIBUTE = 'alt';
|
||||
|
||||
protected function getFullURI(){
|
||||
return $this->getURI().'posts?'
|
||||
.'&page='.$this->getInput('p')
|
||||
return $this->getURI()
|
||||
. 'posts?&page=' . $this->getInput('p')
|
||||
. '&tags=' . urlencode($this->getInput('t'));
|
||||
}
|
||||
|
||||
protected function getTags($element){
|
||||
return $element->find('img', 0)->getAttribute(static::TAGATTRIBUTE);
|
||||
}
|
||||
|
||||
protected function getItemFromElement($element){
|
||||
// Fix links
|
||||
defaultLinkTo($element, $this->getURI());
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = $this->getURI().$element->find('a', 0)->href;
|
||||
$item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute(static::IDATTRIBUTE));
|
||||
$item['uri'] = $element->find('a', 0)->href;
|
||||
$item['postid'] = (int)preg_replace('/[^0-9]/', '', $element->getAttribute(static::IDATTRIBUTE));
|
||||
$item['timestamp'] = time();
|
||||
$thumbnailUri = $this->getURI().$element->find('img', 0)->src;
|
||||
$item['tags'] = $element->find('img', 0)->getAttribute('alt');
|
||||
$thumbnailUri = $element->find('img', 0)->src;
|
||||
$item['tags'] = $this->getTags($element);
|
||||
$item['title'] = $this->getName() . ' | ' . $item['postid'];
|
||||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a><br>Tags: '.$item['tags'];
|
||||
$item['content'] = '<a href="'
|
||||
. $item['uri']
|
||||
. '"><img src="'
|
||||
. $thumbnailUri
|
||||
. '" /></a><br>Tags: '
|
||||
. $item['tags'];
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class DansTonChatBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "Astalaseven";
|
||||
const NAME = "DansTonChat Bridge";
|
||||
const URI = "http://danstonchat.com/";
|
||||
const MAINTAINER = 'Astalaseven';
|
||||
const NAME = 'DansTonChat Bridge';
|
||||
const URI = 'https://danstonchat.com/';
|
||||
const CACHE_TIMEOUT = 21600; //6h
|
||||
const DESCRIPTION = "Returns latest quotes from DansTonChat.";
|
||||
const DESCRIPTION = 'Returns latest quotes from DansTonChat.';
|
||||
|
||||
public function collectData(){
|
||||
|
||||
@@ -15,8 +15,13 @@ class DansTonChatBridge extends BridgeAbstract{
|
||||
foreach($html->find('div.item') as $element) {
|
||||
$item = array();
|
||||
$item['uri'] = $element->find('a', 0)->href;
|
||||
$item['title'] = 'DansTonChat '.$element->find('a', 1)->plaintext;
|
||||
$item['content'] = $element->find('a', 0)->innertext;
|
||||
$titleContent = $element->find('h3 a', 0);
|
||||
if($titleContent) {
|
||||
$item['title'] = 'DansTonChat ' . html_entity_decode($titleContent->plaintext, ENT_QUOTES);
|
||||
} else {
|
||||
$item['title'] = 'DansTonChat';
|
||||
}
|
||||
$item['content'] = $element->find('div.item-content a', 0)->innertext;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class DauphineLibereBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = "qwertygc";
|
||||
const NAME = "Dauphine Bridge";
|
||||
const URI = "http://www.ledauphine.com/";
|
||||
const MAINTAINER = 'qwertygc';
|
||||
const NAME = 'Dauphine Bridge';
|
||||
const URI = 'http://www.ledauphine.com/';
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
const DESCRIPTION = 'Returns the newest articles.';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'u' => array(
|
||||
@@ -43,15 +43,14 @@ class DauphineLibereBridge extends FeedExpander {
|
||||
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
$item['content'] = $this->ExtractContent($item['uri']);
|
||||
$item['content'] = $this->extractContent($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function ExtractContent($url) {
|
||||
private function extractContent($url){
|
||||
$html2 = getSimpleHTMLDOMCached($url);
|
||||
$text = $html2->find('div.column', 0)->innertext;
|
||||
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
587
bridges/DealabsBridge.php
Normal file
587
bridges/DealabsBridge.php
Normal file
@@ -0,0 +1,587 @@
|
||||
<?php
|
||||
class DealabsBridge extends PepperBridgeAbstract {
|
||||
|
||||
const NAME = 'Dealabs Bridge';
|
||||
const URI = 'https://www.dealabs.com/';
|
||||
const DESCRIPTION = 'Affiche les Deals de Dealabs';
|
||||
const MAINTAINER = 'sysadminstory';
|
||||
const PARAMETERS = array(
|
||||
'Recherche par Mot(s) clé(s)' => array (
|
||||
'q' => array(
|
||||
'name' => 'Mot(s) clé(s)',
|
||||
'type' => 'text',
|
||||
'required' => true
|
||||
),
|
||||
'hide_expired' => array(
|
||||
'name' => 'Masquer les éléments expirés',
|
||||
'type' => 'checkbox',
|
||||
'required' => 'true'
|
||||
),
|
||||
'hide_local' => array(
|
||||
'name' => 'Masquer les deals locaux',
|
||||
'type' => 'checkbox',
|
||||
'title' => 'Masquer les deals en magasins physiques',
|
||||
'required' => 'true'
|
||||
),
|
||||
'priceFrom' => array(
|
||||
'name' => 'Prix minimum',
|
||||
'type' => 'text',
|
||||
'title' => 'Prix mnimum en euros',
|
||||
'required' => 'false',
|
||||
'defaultValue' => ''
|
||||
),
|
||||
'priceTo' => array(
|
||||
'name' => 'Prix maximum',
|
||||
'type' => 'text',
|
||||
'title' => 'Prix maximum en euros',
|
||||
'required' => 'false',
|
||||
'defaultValue' => ''
|
||||
),
|
||||
),
|
||||
|
||||
'Deals par groupe' => array(
|
||||
'group' => array(
|
||||
'name' => 'Groupe',
|
||||
'type' => 'list',
|
||||
'required' => 'true',
|
||||
'title' => 'Groupe dont il faut afficher les deals',
|
||||
'values' => array(
|
||||
'Accessoires & gadgets' => 'accessoires-gadgets',
|
||||
'Alimentation & boissons' => 'alimentation-boissons',
|
||||
'Animaux' => 'animaux',
|
||||
'Applis & logiciels' => 'applis-logiciels',
|
||||
'Consoles & jeux vidéo' => 'consoles-jeux-video',
|
||||
'Culture & divertissement' => 'culture-divertissement',
|
||||
'Gratuit' => 'gratuit',
|
||||
'Image, son & vidéo' => 'image-son-video',
|
||||
'Informatique' => 'informatique',
|
||||
'Jeux & jouets' => 'jeux-jouets',
|
||||
'Maison & jardin' => 'maison-jardin',
|
||||
'Mode & accessoires' => 'mode-accessoires',
|
||||
'Santé & cosmétiques' => 'hygiene-sante-cosmetiques',
|
||||
'Services divers' => 'services-divers',
|
||||
'Sports & plein air' => 'sports-plein-air',
|
||||
'Téléphonie' => 'telephonie',
|
||||
'Voyages & sorties' => 'voyages-sorties-restaurants',
|
||||
)
|
||||
),
|
||||
'order' => array(
|
||||
'name' => 'Trier par',
|
||||
'type' => 'list',
|
||||
'required' => 'true',
|
||||
'title' => 'Ordre de tri des deals',
|
||||
'values' => array(
|
||||
'Du deal le plus Hot au moins Hot' => '',
|
||||
'Du deal le plus récent au plus ancien' => '-nouveaux',
|
||||
'Du deal le plus commentés au moins commentés' => '-commentes'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public $lang = array(
|
||||
'bridge-uri' => SELF::URI,
|
||||
'bridge-name' => SELF::NAME,
|
||||
'context-keyword' => 'Recherche par Mot(s) clé(s)',
|
||||
'context-group' => 'Deals par groupe',
|
||||
'uri-group' => '/groupe/',
|
||||
'request-error' => 'Could not request Dealabs',
|
||||
'no-results' => 'Il n'y a rien à afficher pour le moment :(',
|
||||
'relative-date-indicator' => array(
|
||||
'il y a',
|
||||
),
|
||||
'price' => 'Prix',
|
||||
'shipping' => 'Livraison',
|
||||
'origin' => 'Origine',
|
||||
'discount' => 'Réduction',
|
||||
'title-keyword' => 'Recherche',
|
||||
'title-group' => 'Groupe',
|
||||
'local-months' => array(
|
||||
'janvier',
|
||||
'février',
|
||||
'mars',
|
||||
'avril',
|
||||
'mai',
|
||||
'juin',
|
||||
'juillet',
|
||||
'août',
|
||||
'septembre',
|
||||
'octobre',
|
||||
'novembre',
|
||||
'décembre'
|
||||
),
|
||||
'local-time-relative' => array(
|
||||
'il y a ',
|
||||
'min',
|
||||
'h',
|
||||
'jour',
|
||||
'jours',
|
||||
'mois',
|
||||
'ans',
|
||||
'et '
|
||||
),
|
||||
'date-prefixes' => array(
|
||||
'Actualisé ',
|
||||
),
|
||||
'relative-date-alt-prefixes' => array(
|
||||
'Actualisé ',
|
||||
),
|
||||
'relative-date-ignore-suffix' => array(
|
||||
),
|
||||
|
||||
'localdeal' => array(
|
||||
'Local',
|
||||
'Pays d\'expédition'
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
class PepperBridgeAbstract extends BridgeAbstract {
|
||||
|
||||
const CACHE_TIMEOUT = 3600;
|
||||
|
||||
public function collectData(){
|
||||
switch($this->queriedContext) {
|
||||
case $this->i8n('context-keyword'):
|
||||
return $this->collectDataKeywords();
|
||||
break;
|
||||
case $this->i8n('context-group'):
|
||||
return $this->collectDataGroup();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Deal data from the choosen group in the choosed order
|
||||
*/
|
||||
public function collectDataGroup()
|
||||
{
|
||||
|
||||
$group = $this->getInput('group');
|
||||
$order = $this->getInput('order');
|
||||
|
||||
$url = $this->i8n('bridge-uri')
|
||||
. $this->i8n('uri-group') . $group . $order;
|
||||
$this->collectDeals($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Deal data from the choosen keywords and parameters
|
||||
*/
|
||||
public function collectDataKeywords()
|
||||
{
|
||||
$q = $this->getInput('q');
|
||||
$hide_expired = $this->getInput('hide_expired');
|
||||
$hide_local = $this->getInput('hide_local');
|
||||
$priceFrom = $this->getInput('priceFrom');
|
||||
$priceTo = $this->getInput('priceFrom');
|
||||
|
||||
/* Even if the original website uses POST with the search page, GET works too */
|
||||
$url = $this->i8n('bridge-uri')
|
||||
. '/search/advanced?q='
|
||||
. urlencode($q)
|
||||
. '&hide_expired='. $hide_expired
|
||||
. '&hide_local='. $hide_local
|
||||
. '&priceFrom='. $priceFrom
|
||||
. '&priceTo='. $priceTo
|
||||
/* Some default parameters
|
||||
* search_fields : Search in Titres & Descriptions & Codes
|
||||
* sort_by : Sort the search by new deals
|
||||
* time_frame : Search will not be on a limited timeframe
|
||||
*/
|
||||
. '&search_fields[]=1&search_fields[]=2&search_fields[]=3&sort_by=new&time_frame=0';
|
||||
$this->collectDeals($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Deal data using the given URL
|
||||
*/
|
||||
public function collectDeals($url){
|
||||
$html = getSimpleHTMLDOM($url)
|
||||
or returnServerError($this->i8n('request-error'));
|
||||
$list = $html->find('article[id]');
|
||||
|
||||
// Deal Image Link CSS Selector
|
||||
$selectorImageLink = implode(
|
||||
' ', /* Notice this is a space! */
|
||||
array(
|
||||
'cept-thread-image-link',
|
||||
'imgFrame',
|
||||
'imgFrame--noBorder',
|
||||
'thread-listImgCell',
|
||||
)
|
||||
);
|
||||
|
||||
// Deal Link CSS Selector
|
||||
$selectorLink = implode(
|
||||
' ', /* Notice this is a space! */
|
||||
array(
|
||||
'cept-tt',
|
||||
'thread-link',
|
||||
'linkPlain',
|
||||
)
|
||||
);
|
||||
|
||||
// Deal Hotness CSS Selector
|
||||
$selectorHot = implode(
|
||||
' ', /* Notice this is a space! */
|
||||
array(
|
||||
'flex',
|
||||
'flex--align-c',
|
||||
'flex--justify-space-between',
|
||||
'space--b-2',
|
||||
)
|
||||
);
|
||||
|
||||
// Deal Description CSS Selector
|
||||
$selectorDescription = implode(
|
||||
' ', /* Notice this is a space! */
|
||||
array(
|
||||
'cept-description-container',
|
||||
'overflow--wrap-break'
|
||||
)
|
||||
);
|
||||
|
||||
// Deal Date CSS Selector
|
||||
$selectorDate = implode(
|
||||
' ', /* Notice this is a space! */
|
||||
array(
|
||||
'size--all-s',
|
||||
'flex',
|
||||
'flex--justify-e',
|
||||
'flex--grow-1',
|
||||
)
|
||||
);
|
||||
|
||||
// If there is no results, we don't parse the content because it display some random deals
|
||||
$noresult = $html->find('h3[class=size--all-l size--fromW2-xl size--fromW3-xxl]', 0);
|
||||
if ($noresult != null && strpos($noresult->plaintext, $this->i8n('no-results')) !== false) {
|
||||
$this->items = array();
|
||||
} else {
|
||||
foreach ($list as $deal) {
|
||||
$item = array();
|
||||
$item['uri'] = $deal->find('div[class=threadGrid-title]', 0)->find('a', 0)->href;
|
||||
$item['title'] = $deal->find('a[class*='. $selectorLink .']', 0
|
||||
)->plaintext;
|
||||
$item['author'] = $deal->find('span.thread-username', 0)->plaintext;
|
||||
$item['content'] = '<table><tr><td><a href="'
|
||||
. $deal->find(
|
||||
'a[class*='. $selectorImageLink .']', 0)->href
|
||||
. '"><img src="'
|
||||
. $this->getImage($deal)
|
||||
. '"/></td><td><h2><a href="'
|
||||
. $deal->find('a[class*='. $selectorLink .']', 0)->href
|
||||
. '">'
|
||||
. $deal->find('a[class*='. $selectorLink .']', 0)->innertext
|
||||
. '</a></h2>'
|
||||
. $this->getPrice($deal)
|
||||
. $this->getDiscount($deal)
|
||||
. $this->getShipsFrom($deal)
|
||||
. $this->getShippingCost($deal)
|
||||
. $this->GetSource($deal)
|
||||
. $deal->find('div[class*='. $selectorDescription .']', 0)->innertext
|
||||
. '</td><td>'
|
||||
. $deal->find('div[class='. $selectorHot .']', 0)->children(0)->outertext
|
||||
. '</td></table>';
|
||||
$dealDateDiv = $deal->find('div[class*='. $selectorDate .']', 0)
|
||||
->find('span[class=hide--toW3]');
|
||||
$itemDate = end($dealDateDiv)->plaintext;
|
||||
// In case of a Local deal, there is no date, but we can use
|
||||
// this case for other reason (like date not in the last field)
|
||||
if ($this->contains($itemDate, $this->i8n('localdeal'))) {
|
||||
$item['timestamp'] = time();
|
||||
} else if ($this->contains($itemDate, $this->i8n('relative-date-indicator'))) {
|
||||
$item['timestamp'] = $this->relativeDateToTimestamp($itemDate);
|
||||
} else {
|
||||
$item['timestamp'] = $this->parseDate($itemDate);
|
||||
}
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the string $str contains any of the string of the array $arr
|
||||
* @return boolean true if the string matched anything otherwise false
|
||||
*/
|
||||
private function contains($str, array $arr)
|
||||
{
|
||||
foreach ($arr as $a) {
|
||||
if (stripos($str, $a) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Price from a Deal if it exists
|
||||
* @return string String of the deal price
|
||||
*/
|
||||
private function getPrice($deal)
|
||||
{
|
||||
if ($deal->find(
|
||||
'span[class*=thread-price]', 0) != null) {
|
||||
return '<div>'.$this->i8n('price') .' : '
|
||||
. $deal->find(
|
||||
'span[class*=thread-price]', 0
|
||||
)->plaintext
|
||||
. '</div>';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the Shipping costs from a Deal if it exists
|
||||
* @return string String of the deal shipping Cost
|
||||
*/
|
||||
private function getShippingCost($deal)
|
||||
{
|
||||
if ($deal->find('span[class*=cept-shipping-price]', 0) != null) {
|
||||
if ($deal->find('span[class*=cept-shipping-price]', 0)->children(0) != null) {
|
||||
return '<div>'. $this->i8n('shipping') .' : '
|
||||
. $deal->find('span[class*=cept-shipping-price]', 0)->children(0)->innertext
|
||||
. '</div>';
|
||||
} else {
|
||||
return '<div>'. $this->i8n('shipping') .' : '
|
||||
. $deal->find('span[class*=cept-shipping-price]', 0)->innertext
|
||||
. '</div>';
|
||||
}
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the source of a Deal if it exists
|
||||
* @return string String of the deal source
|
||||
*/
|
||||
private function GetSource($deal)
|
||||
{
|
||||
if ($deal->find('a[class=text--color-greyShade]', 0) != null) {
|
||||
return '<div>'. $this->i8n('origin') .' : '
|
||||
. $deal->find('a[class=text--color-greyShade]', 0)->outertext
|
||||
. '</div>';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the original Price and discout from a Deal if it exists
|
||||
* @return string String of the deal original price and discount
|
||||
*/
|
||||
private function getDiscount($deal)
|
||||
{
|
||||
if ($deal->find('span[class*=mute--text text--lineThrough]', 0) != null) {
|
||||
$discountHtml = $deal->find('span[class=space--ml-1 size--all-l size--fromW3-xl]', 0);
|
||||
if ($discountHtml != null) {
|
||||
$discount = $discountHtml->plaintext;
|
||||
} else {
|
||||
$discount = '';
|
||||
}
|
||||
return '<div>'. $this->i8n('discount') .' : <span style="text-decoration: line-through;">'
|
||||
. $deal->find(
|
||||
'span[class*=mute--text text--lineThrough]', 0
|
||||
)->plaintext
|
||||
. '</span> '
|
||||
. $discount
|
||||
. '</div>';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Picture URL from a Deal if it exists
|
||||
* @return string String of the deal Picture URL
|
||||
*/
|
||||
private function getImage($deal)
|
||||
{
|
||||
$selectorLazy = implode(
|
||||
' ', /* Notice this is a space! */
|
||||
array(
|
||||
'thread-image',
|
||||
'width--all-auto',
|
||||
'height--all-auto',
|
||||
'imgFrame-img',
|
||||
'cept-thread-img',
|
||||
'img--dummy',
|
||||
'js-lazy-img'
|
||||
)
|
||||
);
|
||||
|
||||
$selectorPlain = implode(
|
||||
' ', /* Notice this is a space! */
|
||||
array(
|
||||
'thread-image',
|
||||
'width--all-auto',
|
||||
'height--all-auto',
|
||||
'imgFrame-img',
|
||||
'cept-thread-img'
|
||||
)
|
||||
);
|
||||
if ($deal->find('img[class='. $selectorLazy .']', 0) != null) {
|
||||
return json_decode(
|
||||
html_entity_decode(
|
||||
$deal->find('img[class='. $selectorLazy .']', 0)
|
||||
->getAttribute('data-lazy-img')))->{'src'};
|
||||
} else {
|
||||
return $deal->find('img[class*='. $selectorPlain .']', 0 )->src;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the originating country from a Deal if it exists
|
||||
* @return string String of the deal originating country
|
||||
*/
|
||||
private function getShipsFrom($deal)
|
||||
{
|
||||
$selector = implode(
|
||||
' ', /* Notice this is a space! */
|
||||
array(
|
||||
'meta-ribbon',
|
||||
'overflow--wrap-off',
|
||||
'space--l-3',
|
||||
'text--color-greyShade'
|
||||
)
|
||||
);
|
||||
if ($deal->find('span[class='. $selector .']', 0) != null) {
|
||||
return '<div>'
|
||||
. $deal->find('span[class='. $selector .']', 0)->children(2)->plaintext
|
||||
. '</div>';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a local date into a timestamp
|
||||
* @return int timestamp of the input date
|
||||
*/
|
||||
private function parseDate($string)
|
||||
{
|
||||
$month_local = $this->i8n('local-months');
|
||||
$month_en = array(
|
||||
'January',
|
||||
'February',
|
||||
'March',
|
||||
'April',
|
||||
'May',
|
||||
'June',
|
||||
'July',
|
||||
'August',
|
||||
'September',
|
||||
'October',
|
||||
'November',
|
||||
'December'
|
||||
);
|
||||
|
||||
// A date can be prfixed with some words, we remove theme
|
||||
$string = $this->removeDatePrefixes($string);
|
||||
// We translate the local months name in the english one
|
||||
$date_str = trim(str_replace($month_local, $month_en, $string));
|
||||
|
||||
// If the date does not contain any year, we add the current year
|
||||
if (!preg_match('/[0-9]{4}/', $string)) {
|
||||
$date_str .= ' ' . date('Y');
|
||||
}
|
||||
|
||||
// Add the Hour and minutes
|
||||
$date_str .= ' 00:00';
|
||||
|
||||
$date = DateTime::createFromFormat('j F Y H:i', $date_str);
|
||||
return $date->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the prefix of a date if it has one
|
||||
* @return the date without prefiux
|
||||
*/
|
||||
private function removeDatePrefixes($string)
|
||||
{
|
||||
$string = str_replace($this->i8n('date-prefixes'), array(), $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the suffix of a relative date if it has one
|
||||
* @return the relative date without suffixes
|
||||
*/
|
||||
private function removeRelativeDateSuffixes($string)
|
||||
{
|
||||
if (count($this->i8n('relative-date-ignore-suffix')) > 0) {
|
||||
$string = preg_replace($this->i8n('relative-date-ignore-suffix'), '', $string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a relative local date into a timestamp
|
||||
* @return int timestamp of the input date
|
||||
*/
|
||||
private function relativeDateToTimestamp($str) {
|
||||
$date = new DateTime();
|
||||
|
||||
// In case of update date, replace it by the regular relative date first word
|
||||
$str = str_replace($this->i8n('relative-date-alt-prefixes'), $this->i8n('local-time-relative')[0], $str);
|
||||
|
||||
$str = $this->removeRelativeDateSuffixes($str);
|
||||
|
||||
$search = $this->i8n('local-time-relative');
|
||||
|
||||
$replace = array(
|
||||
'-',
|
||||
'minute',
|
||||
'hour',
|
||||
'day',
|
||||
'month',
|
||||
'year',
|
||||
''
|
||||
);
|
||||
|
||||
$date->modify(str_replace($search, $replace, $str));
|
||||
return $date->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the RSS Feed title according to the parameters
|
||||
* @return string the RSS feed Tiyle
|
||||
*/
|
||||
public function getName(){
|
||||
switch($this->queriedContext) {
|
||||
case $this->i8n('context-keyword'):
|
||||
return $this->i8n('bridge-name') . ' - '. $this->i8n('title-keyword') .' : '. $this->getInput('q');
|
||||
break;
|
||||
case $this->i8n('context-group'):
|
||||
$values = $this->getParameters()[$this->i8n('context-group')]['group']['values'];
|
||||
$group = array_search($this->getInput('group'), $values);
|
||||
return $this->i8n('bridge-name') . ' - '. $this->i8n('title-group'). ' : '. $group;
|
||||
break;
|
||||
default: // Return default value
|
||||
return static::NAME;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is some "localisation" function that returns the needed content using
|
||||
* the "$lang" class variable in the local class
|
||||
* @return various the local content needed
|
||||
*/
|
||||
public function i8n($key)
|
||||
{
|
||||
if (array_key_exists($key, $this->lang)) {
|
||||
return $this->lang[$key];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
class DemoBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "teromene";
|
||||
const NAME = "DemoBridge";
|
||||
const URI = "http://github.com/rss-bridge/rss-bridge";
|
||||
const DESCRIPTION = "Bridge used for demos";
|
||||
const MAINTAINER = 'teromene';
|
||||
const NAME = 'DemoBridge';
|
||||
const URI = 'http://github.com/rss-bridge/rss-bridge';
|
||||
const DESCRIPTION = 'Bridge used for demos';
|
||||
|
||||
const PARAMETERS = array(
|
||||
'testCheckbox' => array(
|
||||
@@ -13,7 +13,6 @@ class DemoBridge extends BridgeAbstract{
|
||||
'name' => 'test des checkbox'
|
||||
)
|
||||
),
|
||||
|
||||
'testList' => array(
|
||||
'testList' => array(
|
||||
'type' => 'list',
|
||||
@@ -24,7 +23,6 @@ class DemoBridge extends BridgeAbstract{
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
'testNumber' => array(
|
||||
'testNumber' => array(
|
||||
'type' => 'number',
|
||||
@@ -37,13 +35,12 @@ class DemoBridge extends BridgeAbstract{
|
||||
public function collectData(){
|
||||
|
||||
$item = array();
|
||||
$item['author'] = "Me!";
|
||||
$item['title'] = "Test";
|
||||
$item['content'] = "Awesome content !";
|
||||
$item['id'] = "Lalala";
|
||||
$item['uri'] = "http://example.com/test";
|
||||
$item['author'] = 'Me!';
|
||||
$item['title'] = 'Test';
|
||||
$item['content'] = 'Awesome content !';
|
||||
$item['id'] = 'Lalala';
|
||||
$item['uri'] = 'http://example.com/test';
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
}
|
||||
}
|
||||
|
166
bridges/DemonoidBridge.php
Normal file
166
bridges/DemonoidBridge.php
Normal file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
class DemonoidBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'metaMMA';
|
||||
const NAME = 'Demonoid';
|
||||
const URI = 'https://www.demonoid.pw/';
|
||||
const DESCRIPTION = 'Returns results from search';
|
||||
|
||||
const PARAMETERS = array(array(
|
||||
'q' => array(
|
||||
'name' => 'keywords',
|
||||
'exampleValue' => 'keyword1 keyword2…',
|
||||
'required' => true,
|
||||
),
|
||||
'category' => array(
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'values' => array(
|
||||
'All' => 0,
|
||||
'Movies' => 1,
|
||||
'Music' => 2,
|
||||
'TV' => 3,
|
||||
'Games' => 4,
|
||||
'Applications' => 5,
|
||||
'Pictures' => 8,
|
||||
'Anime' => 9,
|
||||
'Comics' => 10,
|
||||
'Books' => 11,
|
||||
'Audiobooks' => 17
|
||||
)
|
||||
)
|
||||
), array(
|
||||
'catOnly' => array(
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'values' => array(
|
||||
'All' => 0,
|
||||
'Movies' => 1,
|
||||
'Music' => 2,
|
||||
'TV' => 3,
|
||||
'Games' => 4,
|
||||
'Applications' => 5,
|
||||
'Pictures' => 8,
|
||||
'Anime' => 9,
|
||||
'Comics' => 10,
|
||||
'Books' => 11,
|
||||
'Audiobooks' => 17
|
||||
)
|
||||
)
|
||||
), array(
|
||||
'userid' => array(
|
||||
'name' => 'user id',
|
||||
'exampleValue' => '00000',
|
||||
'required' => true,
|
||||
'type' => 'number'
|
||||
),
|
||||
'category' => array(
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'values' => array(
|
||||
'All' => 0,
|
||||
'Movies' => 1,
|
||||
'Music' => 2,
|
||||
'TV' => 3,
|
||||
'Games' => 4,
|
||||
'Applications' => 5,
|
||||
'Pictures' => 8,
|
||||
'Anime' => 9,
|
||||
'Comics' => 10,
|
||||
'Books' => 11,
|
||||
'Audiobooks' => 17
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function collectData() {
|
||||
|
||||
if(!empty($this->getInput('q'))) {
|
||||
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI .
|
||||
'files/?category=' .
|
||||
rawurlencode($this->getInput('category')) .
|
||||
'&subcategory=All&quality=All&seeded=2&external=2&query=' .
|
||||
urlencode($this->getInput('q')) .
|
||||
'&uid=0&sort='
|
||||
) or returnServerError('Could not request Demonoid.');
|
||||
|
||||
} elseif(!empty($this->getInput('catOnly'))) {
|
||||
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI .
|
||||
'files/?uid=0&category=' .
|
||||
rawurlencode($this->getInput('catOnly')) .
|
||||
'&subcategory=0&language=0&seeded=2&quality=0&query=&sort='
|
||||
) or returnServerError('Could not request Demonoid.');
|
||||
|
||||
} elseif(!empty($this->getInput('userid'))) {
|
||||
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI .
|
||||
'files/?uid=' .
|
||||
rawurlencode($this->getInput('userid')) .
|
||||
'&seeded=2'
|
||||
) or returnServerError('Could not request Demonoid.');
|
||||
|
||||
} else {
|
||||
returnServerError('Invalid parameters !');
|
||||
}
|
||||
|
||||
if(preg_match('~No torrents found~', $html)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$table = $html->find('td[class=ctable_content_no_pad]', 0);
|
||||
$cursorCount = 4;
|
||||
$elementCount = 0;
|
||||
while($elementCount != 40) {
|
||||
$elementCount++;
|
||||
$currentElement = $table->find('tr', $cursorCount);
|
||||
if(preg_match('~items total~', $currentElement)) {
|
||||
break;
|
||||
}
|
||||
$item = array();
|
||||
//Do we have a date ?
|
||||
if(preg_match('~Added.*?(.*)~', $currentElement->plaintext, $dateStr)) {
|
||||
if(preg_match('~today~', $dateStr[0])) {
|
||||
date_default_timezone_set('UTC');
|
||||
$timestamp = mktime(0, 0, 0, gmdate('n'), gmdate('j'), gmdate('Y'));
|
||||
} else {
|
||||
preg_match('~(?<=ed on ).*\d+~', $currentElement->plaintext, $fullDateStr);
|
||||
date_default_timezone_set('UTC');
|
||||
$dateObj = strptime($fullDateStr[0], '%A, %b %d, %Y');
|
||||
$timestamp = mktime(0, 0, 0, $dateObj['tm_mon'] + 1, $dateObj['tm_mday'], 1900 + $dateObj['tm_year']);
|
||||
}
|
||||
$cursorCount++;
|
||||
}
|
||||
|
||||
$content = $table->find('tr', $cursorCount)->find('a', 1);
|
||||
$cursorCount++;
|
||||
$torrentInfo = $table->find('tr', $cursorCount);
|
||||
$item['timestamp'] = $timestamp;
|
||||
$item['title'] = $content->plaintext;
|
||||
$item['id'] = self::URI . $content->href;
|
||||
$item['uri'] = self::URI . $content->href;
|
||||
$item['author'] = $torrentInfo->find('a[class=user]', 0)->plaintext;
|
||||
$item['seeders'] = $torrentInfo->find('font[class=green]', 0)->plaintext;
|
||||
$item['leechers'] = $torrentInfo->find('font[class=red]', 0)->plaintext;
|
||||
$item['size'] = $torrentInfo->find('td', 3)->plaintext;
|
||||
$item['content'] = 'Uploaded by ' . $item['author']
|
||||
. ' , Size ' . $item['size']
|
||||
. '<br>seeders: '
|
||||
. $item['seeders']
|
||||
. ' | leechers: '
|
||||
. $item['leechers']
|
||||
. '<br><a href="'
|
||||
. $item['id']
|
||||
. '">info page</a>';
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
$cursorCount++;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class DeveloppezDotComBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = "polopollo";
|
||||
const NAME = "Developpez.com Actus (FR)";
|
||||
const URI = "http://www.developpez.com/";
|
||||
const MAINTAINER = 'polopollo';
|
||||
const NAME = 'Developpez.com Actus (FR)';
|
||||
const URI = 'https://www.developpez.com/';
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = "Returns the 15 newest posts from DeveloppezDotCom (full text).";
|
||||
const DESCRIPTION = 'Returns the 15 newest posts from DeveloppezDotCom (full text).';
|
||||
|
||||
public function collectData(){
|
||||
$this->collectExpandableDatas(self::URI . 'index/rss', 15);
|
||||
@@ -13,19 +13,13 @@ class DeveloppezDotComBridge extends FeedExpander {
|
||||
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
$item['content'] = $this->DeveloppezDotComExtractContent($item['uri']);
|
||||
$item['content'] = $this->extractContent($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function DeveloppezDotComStripCDATA($string) {
|
||||
$string = str_replace('<![CDATA[', '', $string);
|
||||
$string = str_replace(']]>', '', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
// F***ing quotes from Microsoft Word badly encoded, here was the trick:
|
||||
// http://stackoverflow.com/questions/1262038/how-to-replace-microsoft-encoded-quotes-in-php
|
||||
private function convert_smart_quotes($string)
|
||||
private function convertSmartQuotes($string)
|
||||
{
|
||||
$search = array(chr(145),
|
||||
chr(146),
|
||||
@@ -33,18 +27,20 @@ class DeveloppezDotComBridge extends FeedExpander {
|
||||
chr(148),
|
||||
chr(151));
|
||||
|
||||
$replace = array("'",
|
||||
$replace = array(
|
||||
"'",
|
||||
"'",
|
||||
'"',
|
||||
'"',
|
||||
'-');
|
||||
'-'
|
||||
);
|
||||
|
||||
return str_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
private function DeveloppezDotComExtractContent($url) {
|
||||
private function extractContent($url){
|
||||
$articleHTMLContent = getSimpleHTMLDOMCached($url);
|
||||
$text = $this->convert_smart_quotes($articleHTMLContent->find('div.content', 0)->innertext);
|
||||
$text = $this->convertSmartQuotes($articleHTMLContent->find('div.content', 0)->innertext);
|
||||
$text = utf8_encode($text);
|
||||
return trim($text);
|
||||
}
|
||||
|
120
bridges/DiceBridge.php
Normal file
120
bridges/DiceBridge.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
class DiceBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'rogerdc';
|
||||
const NAME = 'Dice Unofficial RSS';
|
||||
const URI = 'https://www.dice.com/';
|
||||
const DESCRIPTION = 'The Unofficial Dice RSS';
|
||||
// const CACHE_TIMEOUT = 86400; // 1 day
|
||||
|
||||
const PARAMETERS = array(array(
|
||||
'for_one' => array(
|
||||
'name' => 'With at least one of the words',
|
||||
'required' => false,
|
||||
),
|
||||
'for_all' => array(
|
||||
'name' => 'With all of the words',
|
||||
'required' => false,
|
||||
),
|
||||
'for_exact' => array(
|
||||
'name' => 'With the exact phrase',
|
||||
'required' => false,
|
||||
),
|
||||
'for_none' => array(
|
||||
'name' => 'With none of these words',
|
||||
'required' => false,
|
||||
),
|
||||
'for_jt' => array(
|
||||
'name' => 'Within job title',
|
||||
'required' => false,
|
||||
),
|
||||
'for_com' => array(
|
||||
'name' => 'Within company name',
|
||||
'required' => false,
|
||||
),
|
||||
'for_loc' => array(
|
||||
'name' => 'City, State, or ZIP code',
|
||||
'required' => false,
|
||||
),
|
||||
'radius' => array(
|
||||
'name' => 'Radius in miles',
|
||||
'type' => 'list',
|
||||
'required' => false,
|
||||
'values' => array(
|
||||
'Exact Location' => 'El',
|
||||
'Within 5 miles' => '5',
|
||||
'Within 10 miles' => '10',
|
||||
'Within 20 miles' => '20',
|
||||
'Within 30 miles' => '0',
|
||||
'Within 40 miles' => '40',
|
||||
'Within 50 miles' => '50',
|
||||
'Within 75 miles' => '75',
|
||||
'Within 100 miles' => '100',
|
||||
),
|
||||
'defaultValue' => '0',
|
||||
),
|
||||
'jtype' => array(
|
||||
'name' => 'Job type',
|
||||
'type' => 'list',
|
||||
'required' => false,
|
||||
'values' => array(
|
||||
'Full-Time' => 'Full Time',
|
||||
'Part-Time' => 'Part Time',
|
||||
'Contract - Independent' => 'Contract Independent',
|
||||
'Contract - W2' => 'Contract W2',
|
||||
'Contract to Hire - Independent' => 'C2H Independent',
|
||||
'Contract to Hire - W2' => 'C2H W2',
|
||||
'Third Party - Contract - Corp-to-Corp' => 'Contract Corp-To-Corp',
|
||||
'Third Party - Contract to Hire - Corp-to-Corp' => 'C2H Corp-To-Corp',
|
||||
),
|
||||
'defaultValue' => 'Full Time',
|
||||
),
|
||||
'telecommute' => array(
|
||||
'name' => 'Telecommute',
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
));
|
||||
|
||||
public function collectData() {
|
||||
$uri = 'https://www.dice.com/jobs/advancedResult.html';
|
||||
$uri .= '?for_one=' . urlencode($this->getInput('for_one'));
|
||||
$uri .= '&for_all=' . urlencode($this->getInput('for_all'));
|
||||
$uri .= '&for_exact=' . urlencode($this->getInput('for_exact'));
|
||||
$uri .= '&for_none=' . urlencode($this->getInput('for_none'));
|
||||
$uri .= '&for_jt=' . urlencode($this->getInput('for_jt'));
|
||||
$uri .= '&for_com=' . urlencode($this->getInput('for_com'));
|
||||
$uri .= '&for_loc=' . urlencode($this->getInput('for_loc'));
|
||||
if ($this->getInput('jtype')) {
|
||||
$uri .= '&jtype=' . urlencode($this->getInput('jtype'));
|
||||
}
|
||||
$uri .= '&sort=date&limit=100';
|
||||
$uri .= '&radius=' . urlencode($this->getInput('radius'));
|
||||
if ($this->getInput('telecommute')) {
|
||||
$uri .= '&telecommute=true';
|
||||
}
|
||||
|
||||
$html = getSimpleHTMLDOM($uri)
|
||||
or returnServerError('Could not request Dice.');
|
||||
foreach($html->find('div.complete-serp-result-div') as $element) {
|
||||
$item = array();
|
||||
// Title
|
||||
$masterLink = $element->find('a[id^=position]', 0);
|
||||
$item['title'] = $masterLink->title;
|
||||
// URL
|
||||
$uri = $masterLink->href;
|
||||
// $uri = substr($uri, 0, strrpos($uri, '?'));
|
||||
$item['uri'] = substr($uri, 0, strrpos($uri, '?'));
|
||||
// ID
|
||||
$item['id'] = $masterLink->value;
|
||||
// Image
|
||||
$image = $element->find('img', 0);
|
||||
if ($image)
|
||||
$item['image'] = $image->getAttribute('src');
|
||||
// Content
|
||||
$shortdesc = $element->find('.shortdesc', '0');
|
||||
$shortdesc = ($shortdesc) ? $shortdesc->innertext : '';
|
||||
$item['content'] = $shortdesc;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
@@ -9,7 +9,8 @@ class DilbertBridge extends BridgeAbstract {
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request Dilbert: '.$this->getURI());
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request Dilbert: ' . $this->getURI());
|
||||
|
||||
foreach($html->find('section.comic-item') as $element) {
|
||||
|
||||
@@ -33,4 +34,3 @@ class DilbertBridge extends BridgeAbstract {
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
112
bridges/DiscogsBridge.php
Normal file
112
bridges/DiscogsBridge.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
class DiscogsBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'teromene';
|
||||
const NAME = 'DiscogsBridge';
|
||||
const URI = 'https://www.discogs.com/';
|
||||
const DESCRIPTION = 'Returns releases from discogs';
|
||||
const PARAMETERS = array(
|
||||
'Artist Releases' => array(
|
||||
'artistid' => array(
|
||||
'name' => 'Artist ID',
|
||||
'type' => 'number',
|
||||
)
|
||||
),
|
||||
'Label Releases' => array(
|
||||
'labelid' => array(
|
||||
'name' => 'Label ID',
|
||||
'type' => 'number',
|
||||
)
|
||||
),
|
||||
'User Wantlist' => array(
|
||||
'username_wantlist' => array(
|
||||
'name' => 'Username',
|
||||
'type' => 'text',
|
||||
)
|
||||
),
|
||||
'User Folder' => array(
|
||||
'username_folder' => array(
|
||||
'name' => 'Username',
|
||||
'type' => 'text',
|
||||
),
|
||||
'folderid' => array(
|
||||
'name' => 'Folder ID',
|
||||
'type' => 'number',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function collectData() {
|
||||
|
||||
if(!empty($this->getInput('artistid')) || !empty($this->getInput('labelid'))) {
|
||||
|
||||
if(!empty($this->getInput('artistid'))) {
|
||||
$data = getContents('https://api.discogs.com/artists/'
|
||||
. $this->getInput('artistid')
|
||||
. '/releases?sort=year&sort_order=desc')
|
||||
or returnServerError('Unable to query discogs !');
|
||||
} elseif(!empty($this->getInput('labelid'))) {
|
||||
$data = getContents('https://api.discogs.com/labels/'
|
||||
. $this->getInput('labelid')
|
||||
. '/releases?sort=year&sort_order=desc')
|
||||
or returnServerError('Unable to query discogs !');
|
||||
}
|
||||
|
||||
$jsonData = json_decode($data, true);
|
||||
foreach($jsonData['releases'] as $release) {
|
||||
|
||||
$item = array();
|
||||
$item['author'] = $release['artist'];
|
||||
$item['title'] = $release['title'];
|
||||
$item['id'] = $release['id'];
|
||||
$resId = array_key_exists('main_release', $release) ? $release['main_release'] : $release['id'];
|
||||
$item['uri'] = self::URI . $this->getInput('artistid') . '/release/' . $resId;
|
||||
$item['timestamp'] = DateTime::createFromFormat('Y', $release['year'])->getTimestamp();
|
||||
$item['content'] = $item['author'] . ' - ' . $item['title'];
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
} elseif(!empty($this->getInput('username_wantlist')) || !empty($this->getInput('username_folder'))) {
|
||||
|
||||
if(!empty($this->getInput('username_wantlist'))) {
|
||||
$data = getContents('https://api.discogs.com/users/'
|
||||
. $this->getInput('username_wantlist')
|
||||
. '/wants?sort=added&sort_order=desc')
|
||||
or returnServerError('Unable to query discogs !');
|
||||
$jsonData = json_decode($data, true)['wants'];
|
||||
|
||||
} elseif(!empty($this->getInput('username_folder'))) {
|
||||
$data = getContents('https://api.discogs.com/users/'
|
||||
. $this->getInput('username_folder')
|
||||
. '/collection/folders/'
|
||||
. $this->getInput('folderid')
|
||||
.'/releases?sort=added&sort_order=desc')
|
||||
or returnServerError('Unable to query discogs !');
|
||||
$jsonData = json_decode($data, true)['releases'];
|
||||
}
|
||||
foreach($jsonData as $element) {
|
||||
|
||||
$infos = $element['basic_information'];
|
||||
$item = array();
|
||||
$item['title'] = $infos['title'];
|
||||
$item['author'] = $infos['artists'][0]['name'];
|
||||
$item['id'] = $infos['artists'][0]['id'];
|
||||
$item['uri'] = self::URI . $infos['artists'][0]['id'] . '/release/' . $infos['id'];
|
||||
$item['timestamp'] = strtotime($element['date_added']);
|
||||
$item['content'] = $item['author'] . ' - ' . $item['title'];
|
||||
$this->items[] = $item;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getURI() {
|
||||
return self::URI;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return static::NAME;
|
||||
}
|
||||
}
|
@@ -2,10 +2,8 @@
|
||||
require_once('Shimmie2Bridge.php');
|
||||
|
||||
class DollbooruBridge extends Shimmie2Bridge {
|
||||
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Dollbooru";
|
||||
const URI = "http://dollbooru.org/";
|
||||
const DESCRIPTION = "Returns images from given page";
|
||||
|
||||
const MAINTAINER = 'mitsukarenai';
|
||||
const NAME = 'Dollbooru';
|
||||
const URI = 'http://dollbooru.org/';
|
||||
const DESCRIPTION = 'Returns images from given page';
|
||||
}
|
||||
|
91
bridges/DribbbleBridge.php
Normal file
91
bridges/DribbbleBridge.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
class DribbbleBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'quentinus95';
|
||||
const NAME = 'Dribbble popular shots';
|
||||
const URI = 'https://dribbble.com';
|
||||
const CACHE_TIMEOUT = 1800;
|
||||
const DESCRIPTION = 'Returns the newest popular shots from Dribbble.';
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM(self::URI . '/shots')
|
||||
or returnServerError('Error while downloading the website content');
|
||||
|
||||
$json = $this->loadEmbeddedJsonData($html);
|
||||
|
||||
foreach($html->find('li[id^="screenshot-"]') as $shot) {
|
||||
$item = [];
|
||||
|
||||
$additional_data = $this->findJsonForShot($shot, $json);
|
||||
if ($additional_data === null) {
|
||||
$item['uri'] = self::URI . $shot->find('a', 0)->href;
|
||||
$item['title'] = $shot->find('.dribbble-over strong', 0)->plaintext;
|
||||
} else {
|
||||
$item['timestamp'] = strtotime($additional_data['published_at']);
|
||||
$item['uri'] = self::URI . $additional_data['path'];
|
||||
$item['title'] = $additional_data['title'];
|
||||
}
|
||||
|
||||
$item['author'] = trim($shot->find('.attribution-user a', 0)->plaintext);
|
||||
|
||||
$description = $shot->find('.comment', 0);
|
||||
$item['content'] = $description === null ? '' : $description->plaintext;
|
||||
|
||||
$preview_path = $shot->find('picture source', 0)->attr['srcset'];
|
||||
$item['content'] .= $this->getImageTag($preview_path, $item['title']);
|
||||
$item['enclosures'] = [$this->getFullSizeImagePath($preview_path)];
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function loadEmbeddedJsonData($html){
|
||||
$json = [];
|
||||
$scripts = $html->find('script');
|
||||
|
||||
foreach($scripts as $script) {
|
||||
if(strpos($script->innertext, 'newestShots') !== false) {
|
||||
// fix single quotes
|
||||
$script->innertext = str_replace('\'', '"', $script->innertext);
|
||||
|
||||
// fix JavaScript JSON (why do they not adhere to the standard?)
|
||||
$script->innertext = preg_replace('/(\w+):/i', '"\1":', $script->innertext);
|
||||
|
||||
// find beginning of JSON array
|
||||
$start = strpos($script->innertext, '[');
|
||||
|
||||
// find end of JSON array, compensate for missing character!
|
||||
$end = strpos($script->innertext, '];') + 1;
|
||||
|
||||
// convert JSON to PHP array
|
||||
$json = json_decode(substr($script->innertext, $start, $end - $start), true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $json;
|
||||
}
|
||||
|
||||
private function findJsonForShot($shot, $json){
|
||||
foreach($json as $element) {
|
||||
if(strpos($shot->getAttribute('id'), (string)$element['id']) !== false) {
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getImageTag($preview_path, $title){
|
||||
return sprintf(
|
||||
'<br /> <a href="%s"><img src="%s" alt="%s" /></a>',
|
||||
$this->getFullSizeImagePath($preview_path),
|
||||
$preview_path,
|
||||
$title
|
||||
);
|
||||
}
|
||||
|
||||
private function getFullSizeImagePath($preview_path){
|
||||
return str_replace('_1x', '', $preview_path);
|
||||
}
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class DuckDuckGoBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "Astalaseven";
|
||||
const NAME = "DuckDuckGo";
|
||||
const URI = "https://duckduckgo.com/";
|
||||
const MAINTAINER = 'Astalaseven';
|
||||
const NAME = 'DuckDuckGo';
|
||||
const URI = 'https://duckduckgo.com/';
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = "Returns results from DuckDuckGo.";
|
||||
const DESCRIPTION = 'Returns results from DuckDuckGo.';
|
||||
|
||||
const SORT_DATE = '+sort:date';
|
||||
const SORT_RELEVANCE = '';
|
||||
@@ -13,7 +13,8 @@ class DuckDuckGoBridge extends BridgeAbstract{
|
||||
const PARAMETERS = array( array(
|
||||
'u' => array(
|
||||
'name' => 'keyword',
|
||||
'required'=>true),
|
||||
'required' => true
|
||||
),
|
||||
'sort' => array(
|
||||
'name' => 'sort by',
|
||||
'type' => 'list',
|
||||
@@ -27,7 +28,7 @@ class DuckDuckGoBridge extends BridgeAbstract{
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM(self::URI.'html/?q='.$this->getInput('u').$this->getInput('sort'))
|
||||
$html = getSimpleHTMLDOM(self::URI . 'html/?kd=-1&q=' . $this->getInput('u') . $this->getInput('sort'))
|
||||
or returnServerError('Could not request DuckDuckGo.');
|
||||
|
||||
foreach($html->find('div.results_links') as $element) {
|
||||
|
142
bridges/ETTVBridge.php
Normal file
142
bridges/ETTVBridge.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
class ETTVBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'GregThib';
|
||||
const NAME = 'ETTV';
|
||||
const URI = 'https://www.ettv.tv/';
|
||||
const DESCRIPTION = 'Returns list of 20 latest torrents for a specific search.';
|
||||
const CACHE_TIMEOUT = 14400; // 4 hours
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'query' => array(
|
||||
'name' => 'Keywords',
|
||||
'required' => true
|
||||
),
|
||||
'cat' => array(
|
||||
'type' => 'list',
|
||||
'name' => 'Category',
|
||||
'values' => array(
|
||||
'(ALL TYPES)' => '0',
|
||||
'Anime: Movies' => '73',
|
||||
'Anime: Dubbed/Subbed' => '74',
|
||||
'Anime: Others' => '75',
|
||||
'Books: Ebooks' => '53',
|
||||
'Books: Magazines' => '54',
|
||||
'Books: Comics' => '55',
|
||||
'Books: Audio' => '56',
|
||||
'Books: Others' => '68',
|
||||
'Games: Windows' => '57',
|
||||
'Games: Android' => '58',
|
||||
'Games: Others' => '71',
|
||||
'Movies: HD 1080p' => '1',
|
||||
'Movies: HD 720p' => '2',
|
||||
'Movies: UltraHD/4K' => '3',
|
||||
'Movies: XviD' => '42',
|
||||
'Movies: X264/H264' => '47',
|
||||
'Movies: 3D' => '49',
|
||||
'Movies: Dubs/Dual Audio' => '51',
|
||||
'Movies: CAM/TS' => '65',
|
||||
'Movies: BluRay Disc/Remux' => '66',
|
||||
'Movies: DVDR' => '67',
|
||||
'Movies: HEVC/x265' => '76',
|
||||
'Music: MP3' => '59',
|
||||
'Music: FLAC' => '60',
|
||||
'Music: Music Videos' => '61',
|
||||
'Music: Others' => '69',
|
||||
'Software: Windows' => '62',
|
||||
'Software: Android' => '63',
|
||||
'Software: Mac' => '64',
|
||||
'Software: Others' => '70',
|
||||
'TV: HD/X264/H264' => '41',
|
||||
'TV: SD/X264/H264' => '5',
|
||||
'TV: TV Packs' => '7',
|
||||
'TV: SD/XVID' => '50',
|
||||
'TV: Sport' => '72',
|
||||
'TV: HEVC/x265' => '77',
|
||||
'Unsorted: Unsorted' => '78'
|
||||
),
|
||||
'defaultValue' => '(ALL TYPES)'
|
||||
),
|
||||
'status' => array(
|
||||
'type' => 'list',
|
||||
'name' => 'Status',
|
||||
'values' => array(
|
||||
'Active Transfers' => '0',
|
||||
'Included Dead' => '1',
|
||||
'Only Dead' => '2'
|
||||
),
|
||||
'defaultValue' => 'Included Dead'
|
||||
),
|
||||
'lang' => array(
|
||||
'type' => 'list',
|
||||
'name' => 'Lang',
|
||||
'values' => array(
|
||||
'(ALL)' => '0',
|
||||
'Arabic' => '17',
|
||||
'Chinese ' => '10',
|
||||
'Danish' => '13',
|
||||
'Dutch' => '11',
|
||||
'English' => '1',
|
||||
'Finnish' => '18',
|
||||
'French' => '2',
|
||||
'German' => '3',
|
||||
'Greek' => '15',
|
||||
'Hindi' => '8',
|
||||
'Italian' => '4',
|
||||
'Japanese' => '5',
|
||||
'Korean' => '9',
|
||||
'Polish' => '14',
|
||||
'Russian' => '7',
|
||||
'Spanish' => '6',
|
||||
'Turkish' => '16'
|
||||
),
|
||||
'defaultValue' => '(ALL)'
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
// No control on inputs, because all have defaultValue set
|
||||
$query_str = 'torrents-search.php';
|
||||
$query_str .= '?search=' . urlencode('+'.str_replace(' ', ' +', $this->getInput('query')));
|
||||
$query_str .= '&cat=' . $this->getInput('cat');
|
||||
$query_str .= 'incldead&=' . $this->getInput('status');
|
||||
$query_str .= '&lang=' . $this->getInput('lang');
|
||||
$query_str .= '&sort=id&order=desc';
|
||||
|
||||
// Get results page
|
||||
$html = getSimpleHTMLDOM(self::URI . $query_str)
|
||||
or returnServerError('Could not request ' . $this->getName());
|
||||
|
||||
// Loop on each entry
|
||||
foreach($html->find('table.table tr') as $element) {
|
||||
if($element->parent->tag == 'thead') continue;
|
||||
$entry = $element->find('td', 1)->find('a', 0);
|
||||
|
||||
// retrieve result page to get more details
|
||||
$link = rtrim(self::URI, '/') . $entry->href;
|
||||
$page = getSimpleHTMLDOM($link)
|
||||
or returnServerError('Could not request page ' . $link);
|
||||
|
||||
// get details & download links
|
||||
$details = $page->find('fieldset.download table', 0); // WHAT?? It should be the second one…
|
||||
$dllinks = $page->find('div#downloadbox table', 0);
|
||||
|
||||
// fill item
|
||||
$item = array();
|
||||
$item['author'] = $details->children(6)->children(1)->plaintext;
|
||||
$item['title'] = $entry->title;
|
||||
$item['uri'] = $dllinks->children(0)->children(0)->children(0)->href;
|
||||
$item['timestamp'] = strtotime($details->children(7)->children(1)->plaintext);
|
||||
$item['content'] = '';
|
||||
$item['content'] .= '<br/><b>Name: </b>' . $details->children(0)->children(1)->innertext;
|
||||
$item['content'] .= '<br/><b>Lang: </b>' . $details->children(3)->children(1)->innertext;
|
||||
$item['content'] .= '<br/><b>Size: </b>' . $details->children(4)->children(1)->innertext;
|
||||
$item['content'] .= '<br/><b>Hash: </b>' . $details->children(5)->children(1)->innertext;
|
||||
foreach($dllinks->children(0)->children(1)->find('a') as $dl) {
|
||||
$item['content'] .= '<br/>' . $dl->outertext;
|
||||
}
|
||||
$item['content'] .= '<br/><br/>' . $details->children(1)->children(0)->innertext;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,10 +1,11 @@
|
||||
<?php
|
||||
class EZTVBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "alexAubin";
|
||||
const NAME = "EZTV";
|
||||
const URI = "https://eztv.ch/";
|
||||
const DESCRIPTION = "Returns list of *recent* torrents for a specific show on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name.";
|
||||
const MAINTAINER = 'alexAubin';
|
||||
const NAME = 'EZTV';
|
||||
const URI = 'https://eztv.ch/';
|
||||
const DESCRIPTION = 'Returns list of *recent* torrents for a specific show
|
||||
on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name.';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'i' => array(
|
||||
@@ -22,15 +23,15 @@ class EZTVBridge extends BridgeAbstract{
|
||||
$relativeDays = 0;
|
||||
$relativeHours = 0;
|
||||
|
||||
foreach (explode(" ",$relativeReleaseTime) as $relativeTimeElement) {
|
||||
if (substr($relativeTimeElement,-1) == "d") $relativeDays = substr($relativeTimeElement,0,-1);
|
||||
if (substr($relativeTimeElement,-1) == "h") $relativeHours = substr($relativeTimeElement,0,-1);
|
||||
foreach(explode(' ', $relativeReleaseTime) as $relativeTimeElement) {
|
||||
if(substr($relativeTimeElement, -1) == 'd') $relativeDays = substr($relativeTimeElement, 0, -1);
|
||||
if(substr($relativeTimeElement, -1) == 'h') $relativeHours = substr($relativeTimeElement, 0, -1);
|
||||
}
|
||||
return mktime(date('h') - $relativeHours, 0, 0, date('m'), date('d') - $relativeDays, date('Y'));
|
||||
}
|
||||
|
||||
// Loop on show ids
|
||||
$showList = explode(",",$this->getInput('i'));
|
||||
$showList = explode(',', $this->getInput('i'));
|
||||
foreach($showList as $showID) {
|
||||
|
||||
// Get show page
|
||||
|
@@ -1,16 +1,16 @@
|
||||
<?php
|
||||
class EliteDangerousGalnetBridge extends BridgeAbstract
|
||||
{
|
||||
const MAINTAINER = "corenting";
|
||||
const NAME = "Elite: Dangerous Galnet";
|
||||
const URI = "https://community.elitedangerous.com/galnet/";
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = "Returns the latest page of news from Galnet";
|
||||
class EliteDangerousGalnetBridge extends BridgeAbstract {
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
const MAINTAINER = 'corenting';
|
||||
const NAME = 'Elite: Dangerous Galnet';
|
||||
const URI = 'https://community.elitedangerous.com/galnet/';
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = 'Returns the latest page of news from Galnet';
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Error while downloading the website content');
|
||||
|
||||
foreach($html->find('div.article') as $element) {
|
||||
$item = array();
|
||||
|
||||
|
147
bridges/ElloBridge.php
Normal file
147
bridges/ElloBridge.php
Normal file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
class ElloBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'teromene';
|
||||
const NAME = 'Ello Bridge';
|
||||
const URI = 'https://ello.co/';
|
||||
const CACHE_TIMEOUT = 4800; //2hours
|
||||
const DESCRIPTION = 'Returns the newest posts for Ello';
|
||||
|
||||
const PARAMETERS = array(
|
||||
'By User' => array(
|
||||
'u' => array(
|
||||
'name' => 'Username',
|
||||
'required' => true,
|
||||
'title' => 'Username'
|
||||
)
|
||||
),
|
||||
'Search' => array(
|
||||
's' => array(
|
||||
'name' => 'Search',
|
||||
'required' => true,
|
||||
'title' => 'Search'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function collectData() {
|
||||
|
||||
$header = array(
|
||||
'Authorization: Bearer ' . $this->getAPIKey()
|
||||
);
|
||||
|
||||
if(!empty($this->getInput('u'))) {
|
||||
$postData = getContents(self::URI . 'api/v2/users/~' . urlencode($this->getInput('u')) . '/posts', $header) or
|
||||
returnServerError('Unable to query Ello API.');
|
||||
} else {
|
||||
$postData = getContents(self::URI . 'api/v2/posts?terms=' . urlencode($this->getInput('s')), $header) or
|
||||
returnServerError('Unable to query Ello API.');
|
||||
}
|
||||
|
||||
$postData = json_decode($postData);
|
||||
$count = 0;
|
||||
foreach($postData->posts as $post) {
|
||||
|
||||
$item = array();
|
||||
$item['author'] = $this->getUsername($post, $postData);
|
||||
$item['timestamp'] = strtotime($post->created_at);
|
||||
$item['title'] = strip_tags($this->findText($post->summary));
|
||||
$item['content'] = $this->getPostContent($post->body);
|
||||
$item['enclosures'] = $this->getEnclosures($post, $postData);
|
||||
$item['uri'] = self::URI . $item['author'] . '/post/' . $post->token;
|
||||
$content = $post->body;
|
||||
|
||||
$this->items[] = $item;
|
||||
$count += 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function findText($path) {
|
||||
|
||||
foreach($path as $summaryElement) {
|
||||
|
||||
if($summaryElement->kind == 'text') {
|
||||
return $summaryElement->data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
public function getPostContent($path) {
|
||||
|
||||
$content = '';
|
||||
foreach($path as $summaryElement) {
|
||||
|
||||
if($summaryElement->kind == 'text') {
|
||||
$content .= $summaryElement->data;
|
||||
} elseif ($summaryElement->kind == 'image') {
|
||||
$alt = '';
|
||||
if(property_exists($summaryElement->data, 'alt')) {
|
||||
$alt = $summaryElement->data->alt;
|
||||
}
|
||||
$content .= '<img src="' . $summaryElement->data->url . '" alt="' . $alt . '" />';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $content;
|
||||
|
||||
}
|
||||
|
||||
public function getEnclosures($post, $postData) {
|
||||
|
||||
$assets = [];
|
||||
foreach($post->links->assets as $asset) {
|
||||
foreach($postData->linked->assets as $assetLink) {
|
||||
if($asset == $assetLink->id) {
|
||||
$assets[] = $assetLink->attachment->original->url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $assets;
|
||||
|
||||
}
|
||||
|
||||
public function getUsername($post, $postData) {
|
||||
|
||||
foreach($postData->linked->users as $user) {
|
||||
if($user->id == $post->links->author->id) {
|
||||
return $user->username;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getAPIKey() {
|
||||
$cache = Cache::create('FileCache');
|
||||
$cache->setPath(CACHE_DIR);
|
||||
$cache->setParameters(['key']);
|
||||
$key = $cache->loadData();
|
||||
|
||||
if($key == null) {
|
||||
$keyInfo = getContents(self::URI . 'api/webapp-token') or
|
||||
returnServerError('Unable to get token.');
|
||||
$key = json_decode($keyInfo)->token->access_token;
|
||||
$cache->saveData($key);
|
||||
}
|
||||
|
||||
return $key;
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('u'))) {
|
||||
return $this->getInput('u') . ' - Ello Bridge';
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
class ElsevierBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'Pierre Mazière';
|
||||
const NAME = 'Elsevier journals recent articles';
|
||||
const URI = 'http://www.journals.elsevier.com/';
|
||||
@@ -16,7 +17,7 @@ class ElsevierBridge extends BridgeAbstract{
|
||||
));
|
||||
|
||||
// Extracts the list of names from an article as string
|
||||
private function ExtractArticleName ($article){
|
||||
private function extractArticleName($article){
|
||||
$names = $article->find('small', 0);
|
||||
if($names)
|
||||
return trim($names->plaintext);
|
||||
@@ -24,7 +25,7 @@ class ElsevierBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
// Extracts the timestamp from an article
|
||||
private function ExtractArticleTimestamp ($article){
|
||||
private function extractArticleTimestamp($article){
|
||||
$time = $article->find('.article-info', 0);
|
||||
if($time) {
|
||||
$timestring = trim($time->plaintext);
|
||||
@@ -48,7 +49,7 @@ class ElsevierBridge extends BridgeAbstract{
|
||||
}
|
||||
|
||||
// Extracts the content from an article
|
||||
private function ExtractArticleContent ($article){
|
||||
private function extractArticleContent($article){
|
||||
$content = $article->find('.article-content', 0);
|
||||
if($content) {
|
||||
return trim($content->plaintext);
|
||||
@@ -58,17 +59,17 @@ class ElsevierBridge extends BridgeAbstract{
|
||||
|
||||
public function collectData(){
|
||||
$uri = self::URI . $this->getInput('j') . '/recent-articles/';
|
||||
$html = getSimpleHTMLDOM($uri) or returnServerError('No results for Elsevier journal '.$this->getInput('j'));
|
||||
$html = getSimpleHTMLDOM($uri)
|
||||
or returnServerError('No results for Elsevier journal ' . $this->getInput('j'));
|
||||
|
||||
foreach($html->find('.pod-listing') as $article) {
|
||||
$item = array();
|
||||
$item['uri'] = $article->find('.pod-listing-header>a', 0)->getAttribute('href') . '?np=y';
|
||||
$item['title'] = $article->find('.pod-listing-header>a', 0)->plaintext;
|
||||
$item['author'] = $this->ExtractArticleName($article);
|
||||
$item['timestamp'] = $this->ExtractArticleTimestamp($article);
|
||||
$item['content'] = $this->ExtractArticleContent($article);
|
||||
$item['author'] = $this->extractArticleName($article);
|
||||
$item['timestamp'] = $this->extractArticleTimestamp($article);
|
||||
$item['content'] = $this->extractArticleContent($article);
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -8,23 +8,30 @@ class EstCeQuonMetEnProdBridge extends BridgeAbstract {
|
||||
const DESCRIPTION = 'Should we put a website in production today? (French)';
|
||||
|
||||
public function collectData(){
|
||||
function ExtractFromDelimiters($string, $start, $end) {
|
||||
function extractFromDelimiters($string, $start, $end){
|
||||
if(strpos($string, $start) !== false) {
|
||||
$section_retrieved = substr($string, strpos($string, $start) + strlen($start));
|
||||
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
|
||||
return $section_retrieved;
|
||||
} return false;
|
||||
}
|
||||
|
||||
$html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request EstCeQuonMetEnProd: '.$this->getURI());
|
||||
return false;
|
||||
}
|
||||
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request EstCeQuonMetEnProd: ' . $this->getURI());
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = $this->getURI() . '#' . date('Y-m-d');
|
||||
$item['title'] = $this->getName();
|
||||
$item['author'] = 'Nicolas Hoffmann';
|
||||
$item['timestamp'] = strtotime('today midnight');
|
||||
$item['content'] = str_replace('src="/', 'src="'.$this->getURI(), trim(ExtractFromDelimiters($html->outertext, '<body role="document">', '<br /><br />')));
|
||||
$item['content'] = str_replace(
|
||||
'src="/',
|
||||
'src="' . $this->getURI(),
|
||||
trim(extractFromDelimiters($html->outertext, '<body role="document">', '<br /><br />'))
|
||||
);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
83
bridges/EtsyBridge.php
Normal file
83
bridges/EtsyBridge.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
class EtsyBridge extends BridgeAbstract {
|
||||
|
||||
const NAME = 'Etsy search';
|
||||
const URI = 'https://www.etsy.com';
|
||||
const DESCRIPTION = 'Returns feeds for search results';
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const PARAMETERS = array(
|
||||
array(
|
||||
'query' => array(
|
||||
'name' => 'Search query',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'title' => 'Insert your search term here',
|
||||
'exampleValue' => 'Enter your search term'
|
||||
),
|
||||
'queryextension' => array(
|
||||
'name' => 'Query extension',
|
||||
'type' => 'text',
|
||||
'requied' => false,
|
||||
'title' => 'Insert additional query parts here
|
||||
(anything after ?search=<your search query>)',
|
||||
'exampleValue' => '&explicit=1&locationQuery=2921044'
|
||||
),
|
||||
'showimage' => array(
|
||||
'name' => 'Show image in content',
|
||||
'type' => 'checkbox',
|
||||
'requrired' => false,
|
||||
'title' => 'Activate to show the image in the content',
|
||||
'defaultValue' => false
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Failed to receive ' . $this->getURI());
|
||||
|
||||
$results = $html->find('div.block-grid-item');
|
||||
|
||||
foreach($results as $result) {
|
||||
// Skip banner cards (ads for categories)
|
||||
if($result->find('a.banner-card'))
|
||||
continue;
|
||||
|
||||
$item = array();
|
||||
|
||||
$item['title'] = $result->find('a', 0)->title;
|
||||
$item['uri'] = $result->find('a', 0)->href;
|
||||
$item['author'] = $result->find('div.card-shop-name', 0)->plaintext;
|
||||
|
||||
$item['content'] = '<p>'
|
||||
. $result->find('div.card-price', 0)->plaintext
|
||||
. '</p><p>'
|
||||
. $result->find('div.card-title', 0)->plaintext
|
||||
. '</p>';
|
||||
|
||||
$image = $result->find('img.placeholder', 0)->src;
|
||||
|
||||
if($this->getInput('showimage')) {
|
||||
$item['content'] .= '<img src="' . $image . '">';
|
||||
}
|
||||
|
||||
$item['enclosures'] = array($image);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('query'))) {
|
||||
$uri = self::URI . '/search?q=' . urlencode($this->getInput('query'));
|
||||
|
||||
if(!is_null($this->getInput('queryextension'))) {
|
||||
$uri .= $this->getInput('queryextension');
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
}
|
281
bridges/FB2Bridge.php
Normal file
281
bridges/FB2Bridge.php
Normal file
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
class FB2Bridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'teromene';
|
||||
const NAME = 'Facebook Alternate';
|
||||
const URI = 'https://www.facebook.com/';
|
||||
const CACHE_TIMEOUT = 1000;
|
||||
const DESCRIPTION = 'Input a page title or a profile log. For a profile log,
|
||||
please insert the parameter as follow : myExamplePage/132621766841117';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'u' => array(
|
||||
'name' => 'Username',
|
||||
'required' => true
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
|
||||
function extractFromDelimiters($string, $start, $end){
|
||||
if(strpos($string, $start) !== false) {
|
||||
$section_retrieved = substr($string, strpos($string, $start) + strlen($start));
|
||||
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
|
||||
return $section_retrieved;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Utility function for cleaning a Facebook link
|
||||
$unescape_fb_link = function($matches){
|
||||
if(is_array($matches) && count($matches) > 1) {
|
||||
$link = $matches[1];
|
||||
if(strpos($link, '/') === 0)
|
||||
$link = self::URI . $link . '"';
|
||||
if(strpos($link, 'facebook.com/l.php?u=') !== false)
|
||||
$link = urldecode(extractFromDelimiters($link, 'facebook.com/l.php?u=', '&'));
|
||||
return ' href="' . $link . '"';
|
||||
}
|
||||
};
|
||||
|
||||
//Utility function for converting facebook emoticons
|
||||
$unescape_fb_emote = function($matches){
|
||||
static $facebook_emoticons = array(
|
||||
'smile' => ':)',
|
||||
'frown' => ':(',
|
||||
'tongue' => ':P',
|
||||
'grin' => ':D',
|
||||
'gasp' => ':O',
|
||||
'wink' => ';)',
|
||||
'pacman' => ':<',
|
||||
'grumpy' => '>_<',
|
||||
'unsure' => ':/',
|
||||
'cry' => ':\'(',
|
||||
'kiki' => '^_^',
|
||||
'glasses' => '8-)',
|
||||
'sunglasses' => 'B-)',
|
||||
'heart' => '<3',
|
||||
'devil' => ']:D',
|
||||
'angel' => '0:)',
|
||||
'squint' => '-_-',
|
||||
'confused' => 'o_O',
|
||||
'upset' => 'xD',
|
||||
'colonthree' => ':3',
|
||||
'like' => '👍');
|
||||
$len = count($matches);
|
||||
if ($len > 1)
|
||||
for ($i = 1; $i < $len; $i++)
|
||||
foreach ($facebook_emoticons as $name => $emote)
|
||||
if ($matches[$i] === $name)
|
||||
return $emote;
|
||||
return $matches[0];
|
||||
};
|
||||
|
||||
if($this->getInput('u') !== null) {
|
||||
$page = 'https://touch.facebook.com/' . $this->getInput('u');
|
||||
$cookies = $this->getCookies($page);
|
||||
$pageID = $this->getPageID($page, $cookies);
|
||||
|
||||
if($pageID === null) {
|
||||
echo <<<EOD
|
||||
Unable to get the page id. You should consider getting the ID by hand, then importing it into FB2Bridge
|
||||
EOD;
|
||||
die();
|
||||
} elseif($pageID == -1) {
|
||||
echo <<<EOD
|
||||
This page is not accessible without being logged in.
|
||||
EOD;
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
//Build the string for the first request
|
||||
$requestString = 'https://touch.facebook.com/pages_reaction_units/more/?page_id='
|
||||
. $pageID
|
||||
. '&cursor={"card_id"%3A"videos"%2C"has_next_page"%3Atrue}&surface=mobile_page_home&unit_count=8';
|
||||
|
||||
$fileContent = getContents($requestString);
|
||||
|
||||
$articleIndex = 0;
|
||||
$maxArticle = 3;
|
||||
|
||||
$html = $this->buildContent($fileContent);
|
||||
$author = $this->getInput('u');
|
||||
|
||||
foreach($html->find('article') as $content) {
|
||||
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = 'http://touch.facebook.com'
|
||||
. $content->find("div[class='_52jc _5qc4 _24u0 _36xo']", 0)->find('a', 0)->getAttribute('href');
|
||||
|
||||
if($content->find('header', 0) !== null) {
|
||||
$content->find('header', 0)->innertext = '';
|
||||
}
|
||||
|
||||
if($content->find('footer', 0) !== null) {
|
||||
$content->find('footer', 0)->innertext = '';
|
||||
}
|
||||
|
||||
//Remove html nodes, keep only img, links, basic formatting
|
||||
$content = strip_tags($content, '<a><img><i><u><br><p>');
|
||||
|
||||
//Adapt link hrefs: convert relative links into absolute links and bypass external link redirection
|
||||
$content = preg_replace_callback('/ href=\"([^"]+)\"/i', $unescape_fb_link, $content);
|
||||
|
||||
//Clean useless html tag properties and fix link closing tags
|
||||
foreach (array(
|
||||
'onmouseover',
|
||||
'onclick',
|
||||
'target',
|
||||
'ajaxify',
|
||||
'tabindex',
|
||||
'class',
|
||||
'style',
|
||||
'data-[^=]*',
|
||||
'aria-[^=]*',
|
||||
'role',
|
||||
'rel',
|
||||
'id') as $property_name)
|
||||
$content = preg_replace('/ ' . $property_name . '=\"[^"]*\"/i', '', $content);
|
||||
$content = preg_replace('/<\/a [^>]+>/i', '</a>', $content);
|
||||
|
||||
//Convert textual representation of emoticons eg
|
||||
// "<i><u>smile emoticon</u></i>" back to ASCII emoticons eg ":)"
|
||||
$content = preg_replace_callback('/<i><u>([^ <>]+) ([^<>]+)<\/u><\/i>/i', $unescape_fb_emote, $content);
|
||||
|
||||
$item['content'] = $content;
|
||||
|
||||
$title = $author;
|
||||
if (strlen($title) > 24)
|
||||
$title = substr($title, 0, strpos(wordwrap($title, 24), "\n")) . '...';
|
||||
$title = $title . ' | ' . strip_tags($content);
|
||||
if (strlen($title) > 64)
|
||||
$title = substr($title, 0, strpos(wordwrap($title, 64), "\n")) . '...';
|
||||
|
||||
$item['title'] = $title;
|
||||
$item['author'] = $author;
|
||||
|
||||
array_push($this->items, $item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Currently not used. Is used to get more than only 3 elements, as they appear on another page.
|
||||
private function computeNextLink($string, $pageID){
|
||||
|
||||
$regex = implode(
|
||||
'',
|
||||
array(
|
||||
'/timeline_unit',
|
||||
"\\\\\\\\u00253A1",
|
||||
"\\\\\\\\u00253A([0-9]*)",
|
||||
"\\\\\\\\u00253A([0-9]*)",
|
||||
"\\\\\\\\u00253A([0-9]*)",
|
||||
"\\\\\\\\u00253A([0-9]*)/"
|
||||
)
|
||||
);
|
||||
|
||||
preg_match($regex, $string, $result);
|
||||
|
||||
return implode(
|
||||
'',
|
||||
array(
|
||||
'https://touch.facebook.com/pages_reaction_units/more/?page_id=',
|
||||
$pageID,
|
||||
'&cursor=%7B%22timeline_cursor%22%3A%22timeline_unit%3A1%3A',
|
||||
$result[1],
|
||||
'%3A',
|
||||
$result[2],
|
||||
'%3A',
|
||||
$result[3],
|
||||
'%3A',
|
||||
$result[4],
|
||||
'%22%2C%22timeline_section_cursor%22%3A%7B%7D%2C%22',
|
||||
'has_next_page%22%3Atrue%7D&surface=mobile_page_home&unit_count=3'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
//Builds the HTML from the encoded JS that Facebook provides.
|
||||
private function buildContent($pageContent){
|
||||
// The html ends with:
|
||||
// /div>","replaceifexists
|
||||
$regex = '/\\"html\\":(\".+\/div>"),"replace/';
|
||||
preg_match($regex, $pageContent, $result);
|
||||
return str_get_html(html_entity_decode(json_decode($result[1])));
|
||||
}
|
||||
|
||||
|
||||
//Builds the cookie from the page, as Facebook sometimes refuses to give
|
||||
//the page if no cookie is provided.
|
||||
private function getCookies($pageURL){
|
||||
|
||||
$ctx = stream_context_create(array(
|
||||
'http' => array(
|
||||
'user_agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0',
|
||||
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
|
||||
)
|
||||
)
|
||||
);
|
||||
$a = file_get_contents($pageURL, 0, $ctx);
|
||||
|
||||
//First request to get the cookie
|
||||
$cookies = '';
|
||||
foreach($http_response_header as $hdr) {
|
||||
if(strpos($hdr, 'Set-Cookie') !== false) {
|
||||
$cLine = explode(':', $hdr)[1];
|
||||
$cLine = explode(';', $cLine)[0];
|
||||
$cookies .= ';' . $cLine;
|
||||
}
|
||||
}
|
||||
|
||||
return substr($cookies, 1);
|
||||
}
|
||||
|
||||
//Get the page ID from the Facebook page.
|
||||
private function getPageID($page, $cookies){
|
||||
|
||||
$context = stream_context_create(array(
|
||||
'http' => array(
|
||||
'user_agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0',
|
||||
'header' => 'Cookie: ' . $cookies
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$pageContent = file_get_contents($page, 0, $context);
|
||||
|
||||
if(strpos($pageContent, 'signup-button') != false) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Get the page ID if we don't have a captcha
|
||||
$regex = '/page_id=([0-9]*)&/';
|
||||
preg_match($regex, $pageContent, $matches);
|
||||
|
||||
if(count($matches) > 0) {
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
//Get the page ID if we do have a captcha
|
||||
$regex = '/"pageID":"([0-9]*)"/';
|
||||
preg_match($regex, $pageContent, $matches);
|
||||
|
||||
return $matches[1];
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return (isset($this->name) ? $this->name . ' - ' : '') . 'Facebook Bridge';
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
return 'http://facebook.com';
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
return 60 * 60 * 3; // 5 minutes
|
||||
}
|
||||
}
|
54
bridges/FDroidBridge.php
Normal file
54
bridges/FDroidBridge.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
class FDroidBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'Mitsukarenai';
|
||||
const NAME = 'F-Droid Bridge';
|
||||
const URI = 'https://f-droid.org/';
|
||||
const CACHE_TIMEOUT = 60 * 60 * 2; // 2 hours
|
||||
const DESCRIPTION = 'Returns latest added/updated apps on the open-source Android apps repository F-Droid';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'u' => array(
|
||||
'name' => 'Widget selection',
|
||||
'type' => 'list',
|
||||
'required' => true,
|
||||
'values' => array(
|
||||
'Latest added apps' => 'added',
|
||||
'Latest updated apps' => 'updated'
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$url = self::URI;
|
||||
$html = getSimpleHTMLDOM($url)
|
||||
or returnServerError('Could not request F-Droid.');
|
||||
|
||||
// targetting the corresponding widget based on user selection
|
||||
// "updated" is the 4th widget on the page, "added" is the 5th
|
||||
|
||||
switch($this->getInput('u')) {
|
||||
case 'updated':
|
||||
$html_widget = $html->find('div.sidebar-widget', 4);
|
||||
break;
|
||||
default:
|
||||
$html_widget = $html->find('div.sidebar-widget', 5);
|
||||
break;
|
||||
}
|
||||
|
||||
// and now extracting app info from the selected widget (and yeah turns out icons are of heterogeneous sizes)
|
||||
|
||||
foreach($html_widget->find('a') as $element) {
|
||||
$item = array();
|
||||
$item['uri'] = self::URI . $element->href;
|
||||
$item['title'] = $element->find('h4', 0)->plaintext;
|
||||
$item['icon'] = $element->find('img', 0)->src;
|
||||
$item['summary'] = $element->find('span.package-summary', 0)->plaintext;
|
||||
$item['content'] = '
|
||||
<a href="'.$item['uri'].'">
|
||||
<img alt="" style="max-height:128px" src="'.$item['icon'].'">
|
||||
</a><br>'.$item['summary'];
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,30 +1,267 @@
|
||||
<?php
|
||||
class FacebookBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "teromene";
|
||||
const NAME = "Facebook";
|
||||
const URI = "https://www.facebook.com/";
|
||||
const MAINTAINER = 'teromene, logmanoriginal';
|
||||
const NAME = 'Facebook';
|
||||
const URI = 'https://www.facebook.com/';
|
||||
const CACHE_TIMEOUT = 300; // 5min
|
||||
const DESCRIPTION = "Input a page title or a profile log. For a profile log, please insert the parameter as follow : myExamplePage/132621766841117";
|
||||
const DESCRIPTION = 'Input a page title or a profile log. For a profile log,
|
||||
please insert the parameter as follow : myExamplePage/132621766841117';
|
||||
|
||||
const PARAMETERS =array( array(
|
||||
const PARAMETERS = array(
|
||||
'User' => array(
|
||||
'u' => array(
|
||||
'name' => 'Username',
|
||||
'required' => true
|
||||
),
|
||||
'media_type' => array(
|
||||
'name' => 'Media type',
|
||||
'type' => 'list',
|
||||
'required' => false,
|
||||
'values' => array(
|
||||
'All' => 'all',
|
||||
'Video' => 'video',
|
||||
'No Video' => 'novideo'
|
||||
),
|
||||
'defaultValue' => 'all'
|
||||
),
|
||||
'skip_reviews' => array(
|
||||
'name' => 'Skip reviews',
|
||||
'type' => 'checkbox',
|
||||
'required' => false,
|
||||
'defaultValue' => false,
|
||||
'title' => 'Feed includes reviews when checked'
|
||||
)
|
||||
));
|
||||
),
|
||||
'Group' => array(
|
||||
'g' => array(
|
||||
'name' => 'Group',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'exampleValue' => 'https://www.facebook.com/groups/743149642484225',
|
||||
'title' => 'Insert group name or facebook group URL'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
private $authorName = '';
|
||||
private $groupName = '';
|
||||
|
||||
public function getURI() {
|
||||
$uri = self::URI;
|
||||
|
||||
switch($this->queriedContext) {
|
||||
|
||||
case 'Group':
|
||||
$uri .= 'groups/' . $this->sanitizeGroup(filter_var($this->getInput('g'), FILTER_SANITIZE_URL));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return $uri .= '?_fb_noscript=1';
|
||||
}
|
||||
|
||||
public function collectData() {
|
||||
|
||||
switch($this->queriedContext) {
|
||||
|
||||
case 'Group':
|
||||
$this->collectGroupData();
|
||||
break;
|
||||
|
||||
case 'User':
|
||||
$this->collectUserData();
|
||||
break;
|
||||
|
||||
default:
|
||||
returnClientError('Unknown context: "' . $this->queriedContext . '"!');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region Group
|
||||
|
||||
private function collectGroupData() {
|
||||
|
||||
$header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n");
|
||||
|
||||
$html = getSimpleHTMLDOM($this->getURI(), $header)
|
||||
or returnServerError('Failed loading facebook page: ' . $this->getURI());
|
||||
|
||||
if(!$this->isPublicGroup($html)) {
|
||||
returnClientError('This group is not public! RSS-Bridge only supports public groups!');
|
||||
}
|
||||
|
||||
defaultLinkTo($html, substr(self::URI, 0, strlen(self::URI) - 1));
|
||||
|
||||
$this->groupName = $this->extractGroupName($html);
|
||||
|
||||
$posts = $html->find('div.userContentWrapper')
|
||||
or returnServerError('Failed finding posts!');
|
||||
|
||||
foreach($posts as $post) {
|
||||
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = $this->extractGroupURI($post);
|
||||
$item['title'] = $this->extractGroupTitle($post);
|
||||
$item['author'] = $this->extractGroupAuthor($post);
|
||||
$item['content'] = $this->extractGroupContent($post);
|
||||
$item['timestamp'] = $this->extractGroupTimestamp($post);
|
||||
$item['enclosures'] = $this->extractGroupEnclosures($post);
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function sanitizeGroup($group) {
|
||||
|
||||
if(filter_var(
|
||||
$group,
|
||||
FILTER_VALIDATE_URL,
|
||||
FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_PATH_REQUIRED)) {
|
||||
// User provided a URL
|
||||
|
||||
$urlparts = parse_url($group);
|
||||
|
||||
if($urlparts['host'] !== parse_url(self::URI)['host']
|
||||
&& 'www.' . $urlparts['host'] !== parse_url(self::URI)['host']) {
|
||||
|
||||
returnClientError('The host you provided is invalid! Received "'
|
||||
. $urlparts['host']
|
||||
. '", expected "'
|
||||
. parse_url(self::URI)['host']
|
||||
. '"!');
|
||||
|
||||
}
|
||||
|
||||
return explode('/', $urlparts['path'])[2];
|
||||
|
||||
} elseif(strpos($group, '/') !== false) {
|
||||
returnClientError('The group you provided is invalid: ' . $group);
|
||||
} else {
|
||||
return $group;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function isPublicGroup($html) {
|
||||
|
||||
// Facebook redirects to the groups about page for non-public groups
|
||||
$about = $html->find('#pagelet_group_about', 0);
|
||||
|
||||
return !($about);
|
||||
|
||||
}
|
||||
|
||||
private function extractGroupName($html) {
|
||||
|
||||
$ogtitle = $html->find('meta[property="og:title"]', 0)
|
||||
or returnServerError('Unable to find group title!');
|
||||
|
||||
return htmlspecialchars_decode($ogtitle->content, ENT_QUOTES);
|
||||
|
||||
}
|
||||
|
||||
private function extractGroupURI($post) {
|
||||
|
||||
$elements = $post->find('a')
|
||||
or returnServerError('Unable to find URI!');
|
||||
|
||||
foreach($elements as $anchor) {
|
||||
|
||||
// Find the one that is a permalink
|
||||
if(strpos($anchor->href, 'permalink') !== false) {
|
||||
return $anchor->href;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
private function extractGroupContent($post) {
|
||||
|
||||
$content = $post->find('div.userContent', 0)
|
||||
or returnServerError('Unable to find user content!');
|
||||
|
||||
return $content->innertext . $content->next_sibling()->innertext;
|
||||
|
||||
}
|
||||
|
||||
private function extractGroupTimestamp($post) {
|
||||
|
||||
$element = $post->find('abbr[data-utime]', 0)
|
||||
or returnServerError('Unable to find timestamp!');
|
||||
|
||||
return $element->getAttribute('data-utime');
|
||||
|
||||
}
|
||||
|
||||
private function extractGroupAuthor($post) {
|
||||
|
||||
$element = $post->find('img', 0)
|
||||
or returnServerError('Unable to find author information!');
|
||||
|
||||
return $element->{'aria-label'};
|
||||
|
||||
}
|
||||
|
||||
private function extractGroupEnclosures($post) {
|
||||
|
||||
$elements = $post->find('div.userContent', 0)->next_sibling()->find('img');
|
||||
|
||||
$enclosures = array();
|
||||
|
||||
foreach($elements as $enclosure) {
|
||||
$enclosures[] = $enclosure->src;
|
||||
}
|
||||
|
||||
return empty($enclosures) ? null : $enclosures;
|
||||
|
||||
}
|
||||
|
||||
private function extractGroupTitle($post) {
|
||||
|
||||
$element = $post->find('h5', 0)
|
||||
or returnServerError('Unable to find title!');
|
||||
|
||||
if(strpos($element->plaintext, 'shared') === false) {
|
||||
|
||||
$content = strip_tags($this->extractGroupContent($post));
|
||||
|
||||
return $this->extractGroupAuthor($post)
|
||||
. ' posted: '
|
||||
. substr(
|
||||
$content,
|
||||
0,
|
||||
strpos(wordwrap($content, 64), "\n")
|
||||
)
|
||||
. '...';
|
||||
|
||||
}
|
||||
|
||||
return $element->plaintext;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private function collectUserData(){
|
||||
|
||||
//Extract a string using start and end delimiters
|
||||
function ExtractFromDelimiters($string, $start, $end) {
|
||||
function extractFromDelimiters($string, $start, $end){
|
||||
if(strpos($string, $start) !== false) {
|
||||
$section_retrieved = substr($string, strpos($string, $start) + strlen($start));
|
||||
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
|
||||
return $section_retrieved;
|
||||
} return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Utility function for cleaning a Facebook link
|
||||
@@ -32,9 +269,9 @@ class FacebookBridge extends BridgeAbstract{
|
||||
if(is_array($matches) && count($matches) > 1) {
|
||||
$link = $matches[1];
|
||||
if(strpos($link, '/') === 0)
|
||||
$link = self::URI.$link.'"';
|
||||
$link = self::URI . $link;
|
||||
if(strpos($link, 'facebook.com/l.php?u=') !== false)
|
||||
$link = urldecode(ExtractFromDelimiters($link, 'facebook.com/l.php?u=', '&'));
|
||||
$link = urldecode(extractFromDelimiters($link, 'facebook.com/l.php?u=', '&'));
|
||||
return ' href="' . $link . '"';
|
||||
}
|
||||
};
|
||||
@@ -75,26 +312,26 @@ class FacebookBridge extends BridgeAbstract{
|
||||
$html = null;
|
||||
|
||||
//Handle captcha response sent by the viewer
|
||||
if (isset($_POST['captcha_response']))
|
||||
{
|
||||
if (isset($_POST['captcha_response'])) {
|
||||
if (session_status() == PHP_SESSION_NONE)
|
||||
session_start();
|
||||
if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action']))
|
||||
{
|
||||
if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action'])) {
|
||||
$captcha_action = $_SESSION['captcha_action'];
|
||||
$captcha_fields = $_SESSION['captcha_fields'];
|
||||
$captcha_fields['captcha_response'] = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['captcha_response']);
|
||||
$http_options = array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'user_agent'=> ini_get('user_agent'),
|
||||
'header'=>array("Content-type: application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscript=1\r\n"),
|
||||
'content' => http_build_query($captcha_fields),
|
||||
),
|
||||
$captcha_fields['captcha_response'] = preg_replace('/[^a-zA-Z0-9]+/', '', $_POST['captcha_response']);
|
||||
|
||||
$header = array("Content-type:
|
||||
application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscript=1\r\n");
|
||||
$opts = array(
|
||||
CURLOPT_POST => 1,
|
||||
CURLOPT_POSTFIELDS => http_build_query($captcha_fields)
|
||||
);
|
||||
$context = stream_context_create($http_options);
|
||||
$html = getContents($captcha_action, false, $context);
|
||||
if ($html === FALSE) { returnServerError('Failed to submit captcha response back to Facebook'); }
|
||||
|
||||
$html = getContents($captcha_action, $header, $opts);
|
||||
|
||||
if($html === false) {
|
||||
returnServerError('Failed to submit captcha response back to Facebook');
|
||||
}
|
||||
unset($_SESSION['captcha_fields']);
|
||||
$html = str_get_html($html);
|
||||
}
|
||||
@@ -104,19 +341,52 @@ class FacebookBridge extends BridgeAbstract{
|
||||
|
||||
//Retrieve page contents
|
||||
if(is_null($html)) {
|
||||
if (!strpos($this->getInput('u'), "/")) {
|
||||
$html = getSimpleHTMLDOM(self::URI.urlencode($this->getInput('u')).'?_fb_noscript=1')
|
||||
$header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n");
|
||||
|
||||
// Check if the user provided a fully qualified URL
|
||||
if (filter_var($this->getInput('u'), FILTER_VALIDATE_URL)) {
|
||||
|
||||
$urlparts = parse_url($this->getInput('u'));
|
||||
|
||||
if($urlparts['host'] !== parse_url(self::URI)['host']) {
|
||||
returnClientError('The host you provided is invalid! Received "'
|
||||
. $urlparts['host']
|
||||
. '", expected "'
|
||||
. parse_url(self::URI)['host']
|
||||
. '"!');
|
||||
}
|
||||
|
||||
if(!array_key_exists('path', $urlparts)
|
||||
|| $urlparts['path'] === '/') {
|
||||
returnClientError('The URL you provided doesn\'t contain the user name!');
|
||||
}
|
||||
|
||||
$user = explode('/', $urlparts['path'])[1];
|
||||
|
||||
$html = getSimpleHTMLDOM(self::URI . urlencode($user) . '?_fb_noscript=1', $header)
|
||||
or returnServerError('No results for this query.');
|
||||
|
||||
} else {
|
||||
|
||||
// First character cannot be a forward slash
|
||||
if(strpos($this->getInput('u'), '/') === 0) {
|
||||
returnClientError('Remove leading slash "/" from the username!');
|
||||
}
|
||||
|
||||
if(!strpos($this->getInput('u'), '/')) {
|
||||
$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1', $header)
|
||||
or returnServerError('No results for this query.');
|
||||
} else {
|
||||
$html = getSimpleHTMLDOM(self::URI.'pages/'.$this->getInput('u').'?_fb_noscript=1')
|
||||
$html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1', $header)
|
||||
or returnServerError('No results for this query.');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//Handle captcha form?
|
||||
$captcha = $html->find('div.captcha_interstitial', 0);
|
||||
if (!is_null($captcha))
|
||||
{
|
||||
if (!is_null($captcha)) {
|
||||
//Save form for submitting after getting captcha response
|
||||
if (session_status() == PHP_SESSION_NONE)
|
||||
session_start();
|
||||
@@ -124,60 +394,134 @@ class FacebookBridge extends BridgeAbstract{
|
||||
foreach ($captcha->find('input, button') as $input)
|
||||
$captcha_fields[$input->name] = $input->value;
|
||||
$_SESSION['captcha_fields'] = $captcha_fields;
|
||||
$_SESSION['captcha_action'] = self::URI.$captcha->find('form', 0)->action;
|
||||
$_SESSION['captcha_action'] = $captcha->find('form', 0)->action;
|
||||
|
||||
//Show captcha filling form to the viewer, proxying the captcha image
|
||||
$img = base64_encode(getContents($captcha->find('img', 0)->src));
|
||||
header('HTTP/1.1 500 '.Http::getMessageForCode(500));
|
||||
http_response_code(500);
|
||||
header('Content-Type: text/html');
|
||||
die('<form method="post" action="?'.$_SERVER['QUERY_STRING'].'">'
|
||||
.'<h2>Facebook captcha challenge</h2>'
|
||||
.'<p>Unfortunately, rss-bridge cannot fetch the requested page.<br />'
|
||||
.'Facebook wants rss-bridge to resolve the following captcha:</p>'
|
||||
.'<p><img src="data:image/png;base64,'.$img.'" /></p>'
|
||||
.'<p><b>Response:</b> <input name="captcha_response" placeholder="please fill in" />'
|
||||
.'<input type="submit" value="Submit!" /></p>'
|
||||
.'</form>');
|
||||
$message = <<<EOD
|
||||
<form method="post" action="?{$_SERVER['QUERY_STRING']}">
|
||||
<h2>Facebook captcha challenge</h2>
|
||||
<p>Unfortunately, rss-bridge cannot fetch the requested page.<br />
|
||||
Facebook wants rss-bridge to resolve the following captcha:</p>
|
||||
<p><img src="data:image/png;base64,{$img}" /></p>
|
||||
<p><b>Response:</b> <input name="captcha_response" placeholder="please fill in" />
|
||||
<input type="submit" value="Submit!" /></p>
|
||||
</form>
|
||||
EOD;
|
||||
die($message);
|
||||
}
|
||||
|
||||
//No captcha? We can carry on retrieving page contents :)
|
||||
$element = $html->find('#pagelet_timeline_main_column')[0]->children(0)->children(0)->children(0)->next_sibling()->children(0);
|
||||
//First, we check wether the page is public or not
|
||||
$loginForm = $html->find('._585r', 0);
|
||||
if($loginForm != null) {
|
||||
returnServerError('You must be logged in to view this page. This is not supported by RSS-Bridge.');
|
||||
}
|
||||
|
||||
$element = $html
|
||||
->find('#pagelet_timeline_main_column')[0]
|
||||
->children(0)
|
||||
->children(0)
|
||||
->children(0)
|
||||
->next_sibling()
|
||||
->children(0);
|
||||
|
||||
if(isset($element)) {
|
||||
|
||||
$author = str_replace(' | Facebook', '', $html->find('title#pageTitle', 0)->innertext);
|
||||
$profilePic = 'https://graph.facebook.com/'.$this->getInput('u').'/picture?width=200&height=200';
|
||||
$profilePic = 'https://graph.facebook.com/'
|
||||
. $this->getInput('u')
|
||||
. '/picture?width=200&height=200';
|
||||
|
||||
$this->authorName = $author;
|
||||
|
||||
foreach($element->children() as $post) {
|
||||
foreach($element->children() as $cell) {
|
||||
// Manage summary posts
|
||||
if(strpos($cell->class, '_3xaf') !== false) {
|
||||
$posts = $cell->children();
|
||||
} else {
|
||||
$posts = array($cell);
|
||||
}
|
||||
|
||||
// Optionally skip reviews
|
||||
if($this->getInput('skip_reviews')
|
||||
&& !is_null($cell->find('#review_composer_container', 0))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach($posts as $post) {
|
||||
// Check media type
|
||||
switch($this->getInput('media_type')) {
|
||||
case 'all': break;
|
||||
case 'video':
|
||||
if(empty($post->find('[aria-label=Video]'))) continue 2;
|
||||
break;
|
||||
case 'novideo':
|
||||
if(!empty($post->find('[aria-label=Video]'))) continue 2;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
$item = array();
|
||||
|
||||
if(count($post->find('abbr')) > 0) {
|
||||
|
||||
//Retrieve post contents
|
||||
$content = preg_replace('/(?i)><div class=\"clearfix([^>]+)>(.+?)div\ class=\"userContent\"/i', '', $post);
|
||||
$content = preg_replace('/(?i)><div class=\"_59tj([^>]+)>(.+?)<\/div><\/div><a/i', '', $content);
|
||||
$content = preg_replace('/(?i)><div class=\"_3dp([^>]+)>(.+?)div\ class=\"[^u]+userContent\"/i', '', $content);
|
||||
$content = preg_replace('/(?i)><div class=\"_4l5([^>]+)>(.+?)<\/div>/i', '', $content);
|
||||
$content = preg_replace(
|
||||
'/(?i)><div class=\"clearfix([^>]+)>(.+?)div\ class=\"userContent\"/i',
|
||||
'',
|
||||
$post);
|
||||
|
||||
$content = preg_replace(
|
||||
'/(?i)><div class=\"_59tj([^>]+)>(.+?)<\/div><\/div><a/i',
|
||||
'',
|
||||
$content);
|
||||
|
||||
$content = preg_replace(
|
||||
'/(?i)><div class=\"_3dp([^>]+)>(.+?)div\ class=\"[^u]+userContent\"/i',
|
||||
'',
|
||||
$content);
|
||||
|
||||
$content = preg_replace(
|
||||
'/(?i)><div class=\"_4l5([^>]+)>(.+?)<\/div>/i',
|
||||
'',
|
||||
$content);
|
||||
|
||||
//Remove html nodes, keep only img, links, basic formatting
|
||||
$content = strip_tags($content,'<a><img><i><u>');
|
||||
$content = strip_tags($content, '<a><img><i><u><br><p>');
|
||||
|
||||
//Adapt link hrefs: convert relative links into absolute links and bypass external link redirection
|
||||
$content = preg_replace_callback('/ href=\"([^"]+)\"/i', $unescape_fb_link, $content);
|
||||
|
||||
//Clean useless html tag properties and fix link closing tags
|
||||
foreach (array('onmouseover', 'onclick', 'target', 'ajaxify', 'tabindex',
|
||||
'class', 'style', 'data-[^=]*', 'aria-[^=]*', 'role', 'rel', 'id') as $property_name)
|
||||
foreach (array(
|
||||
'onmouseover',
|
||||
'onclick',
|
||||
'target',
|
||||
'ajaxify',
|
||||
'tabindex',
|
||||
'class',
|
||||
'style',
|
||||
'data-[^=]*',
|
||||
'aria-[^=]*',
|
||||
'role',
|
||||
'rel',
|
||||
'id') as $property_name)
|
||||
$content = preg_replace('/ ' . $property_name . '=\"[^"]*\"/i', '', $content);
|
||||
$content = preg_replace('/<\/a [^>]+>/i', '</a>', $content);
|
||||
|
||||
//Convert textual representation of emoticons eg "<i><u>smile emoticon</u></i>" back to ASCII emoticons eg ":)"
|
||||
$content = preg_replace_callback('/<i><u>([^ <>]+) ([^<>]+)<\/u><\/i>/i', $unescape_fb_emote, $content);
|
||||
//Convert textual representation of emoticons eg
|
||||
//"<i><u>smile emoticon</u></i>" back to ASCII emoticons eg ":)"
|
||||
$content = preg_replace_callback(
|
||||
'/<i><u>([^ <>]+) ([^<>]+)<\/u><\/i>/i',
|
||||
$unescape_fb_emote,
|
||||
$content
|
||||
);
|
||||
|
||||
//Retrieve date of the post
|
||||
$date = $post->find("abbr")[0];
|
||||
$date = $post->find('abbr')[0];
|
||||
if(isset($date) && $date->hasAttribute('data-utime')) {
|
||||
$date = $date->getAttribute('data-utime');
|
||||
} else {
|
||||
@@ -192,9 +536,11 @@ class FacebookBridge extends BridgeAbstract{
|
||||
if(strlen($title) > 64)
|
||||
$title = substr($title, 0, strpos(wordwrap($title, 64), "\n")) . '...';
|
||||
|
||||
$uri = self::URI . $post->find('abbr')[0]->parent()->getAttribute('href');
|
||||
|
||||
//Build and add final item
|
||||
$item['uri'] = self::URI.$post->find('abbr')[0]->parent()->getAttribute('href');
|
||||
$item['content'] = $content;
|
||||
$item['uri'] = htmlspecialchars_decode($uri);
|
||||
$item['content'] = htmlspecialchars_decode($content);
|
||||
$item['title'] = $title;
|
||||
$item['author'] = $author;
|
||||
$item['timestamp'] = $date;
|
||||
@@ -203,8 +549,27 @@ class FacebookBridge extends BridgeAbstract{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return (isset($this->authorName) ? $this->authorName.' - ' : '').'Facebook Bridge';
|
||||
|
||||
switch($this->queriedContext) {
|
||||
|
||||
case 'User':
|
||||
if(!empty($this->authorName)) {
|
||||
return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName
|
||||
. ' - Facebook Bridge';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Group':
|
||||
if(!empty($this->groupName)) {
|
||||
return $this->groupName . ' - Facebook Bridge';
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
}
|
||||
|
@@ -1,23 +1,29 @@
|
||||
<?php
|
||||
class FierPandaBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "snroki";
|
||||
const NAME = "Fier Panda Bridge";
|
||||
const URI = "http://www.fier-panda.fr/";
|
||||
const MAINTAINER = 'snroki';
|
||||
const NAME = 'Fier Panda Bridge';
|
||||
const URI = 'http://www.fier-panda.fr/';
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = "Returns latest articles from Fier Panda.";
|
||||
const DESCRIPTION = 'Returns latest articles from Fier Panda.';
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM(self::URI) or returnServerError('Could not request Fier Panda.');
|
||||
|
||||
foreach($html->find('div.container-content article') as $element) {
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request Fier Panda.');
|
||||
|
||||
defaultLinkTo($html, static::URI);
|
||||
|
||||
foreach($html->find('article') as $article) {
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = $this->getURI().$element->find('a', 0)->href;
|
||||
$item['title'] = trim($element->find('h1 a', 0)->innertext);
|
||||
// Remove the link at the end of the article
|
||||
$element->find('p a', 0)->outertext = '';
|
||||
$item['content'] = $element->find('p', 0)->innertext;
|
||||
|
||||
$item['uri'] = $article->find('a', 0)->href;
|
||||
$item['title'] = $article->find('a', 0)->title;
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
100
bridges/FilterBridge.php
Normal file
100
bridges/FilterBridge.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
class FilterBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = 'Frenzie';
|
||||
const NAME = 'Filter';
|
||||
const CACHE_TIMEOUT = 3600; // 1h
|
||||
const DESCRIPTION = 'Filters a feed of your choice';
|
||||
|
||||
const PARAMETERS = array(array(
|
||||
'url' => array(
|
||||
'name' => 'Feed URL',
|
||||
'required' => true,
|
||||
),
|
||||
'filter' => array(
|
||||
'name' => 'Filter item title (regular expression)',
|
||||
'required' => false,
|
||||
),
|
||||
'filter_type' => array(
|
||||
'name' => 'Filter type',
|
||||
'type' => 'list',
|
||||
'required' => false,
|
||||
'values' => array(
|
||||
'Permit' => 'permit',
|
||||
'Block' => 'block',
|
||||
),
|
||||
'defaultValue' => 'permit',
|
||||
),
|
||||
'title_from_content' => array(
|
||||
'name' => 'Generate title from content',
|
||||
'type' => 'checkbox',
|
||||
'required' => false,
|
||||
)
|
||||
));
|
||||
|
||||
protected function parseItem($newItem){
|
||||
$item = parent::parseItem($newItem);
|
||||
|
||||
if($this->getInput('title_from_content') && array_key_exists('content', $item)) {
|
||||
|
||||
$content = str_get_html($item['content']);
|
||||
|
||||
$pos = strpos($item['content'], ' ', 50);
|
||||
|
||||
$item['title'] = substr(
|
||||
$content->plaintext,
|
||||
0,
|
||||
$pos
|
||||
);
|
||||
|
||||
if(strlen($content->plaintext) >= $pos) {
|
||||
$item['title'] .= '...';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch(true) {
|
||||
case $this->getFilterType() === 'permit':
|
||||
if (preg_match($this->getFilter(), $item['title'])) {
|
||||
return $item;
|
||||
}
|
||||
break;
|
||||
case $this->getFilterType() === 'block':
|
||||
if (!preg_match($this->getFilter(), $item['title'])) {
|
||||
return $item;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getFilter(){
|
||||
return '/' . $this->getInput('filter') . '/';
|
||||
}
|
||||
|
||||
protected function getFilterType(){
|
||||
return $this->getInput('filter_type');
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
$url = $this->getInput('url');
|
||||
|
||||
if(empty($url)) {
|
||||
$url = parent::getURI();
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
if($this->getInput('url') && substr($this->getInput('url'), 0, strlen('http')) !== 'http') {
|
||||
// just in case someone find a way to access local files by playing with the url
|
||||
returnClientError('The url parameter must either refer to http or https protocol.');
|
||||
}
|
||||
try{
|
||||
$this->collectExpandableDatas($this->getURI());
|
||||
} catch (HttpException $e) {
|
||||
$this->collectExpandableDatas($this->getURI());
|
||||
}
|
||||
}
|
||||
}
|
186
bridges/FlickrBridge.php
Normal file
186
bridges/FlickrBridge.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
/* This is a mashup of FlickrExploreBridge by sebsauvage and FlickrTagBridge
|
||||
* by erwang, providing the functionality of both in one.
|
||||
*/
|
||||
class FlickrBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const NAME = 'Flickr Bridge';
|
||||
const URI = 'https://www.flickr.com/';
|
||||
const CACHE_TIMEOUT = 21600; // 6 hours
|
||||
const DESCRIPTION = 'Returns images from Flickr';
|
||||
|
||||
const PARAMETERS = array(
|
||||
'Explore' => array(),
|
||||
'By keyword' => array(
|
||||
'q' => array(
|
||||
'name' => 'Keyword',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'title' => 'Insert keyword',
|
||||
'exampleValue' => 'bird'
|
||||
)
|
||||
),
|
||||
'By username' => array(
|
||||
'u' => array(
|
||||
'name' => 'Username',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'title' => 'Insert username (as shown in the address bar)',
|
||||
'exampleValue' => 'flickr'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function collectData(){
|
||||
|
||||
switch($this->queriedContext) {
|
||||
|
||||
case 'Explore':
|
||||
$filter = 'photo-lite-models';
|
||||
$html = getSimpleHTMLDOM(self::URI . 'explore')
|
||||
or returnServerError('Could not request Flickr.');
|
||||
break;
|
||||
|
||||
case 'By keyword':
|
||||
$filter = 'photo-lite-models';
|
||||
$html = getSimpleHTMLDOM(self::URI . 'search/?q=' . urlencode($this->getInput('q')) . '&s=rec')
|
||||
or returnServerError('No results for this query.');
|
||||
break;
|
||||
|
||||
case 'By username':
|
||||
$filter = 'photo-models';
|
||||
$html = getSimpleHTMLDOM(self::URI . 'photos/' . urlencode($this->getInput('u')))
|
||||
or returnServerError('Requested username can\'t be found.');
|
||||
break;
|
||||
|
||||
default:
|
||||
returnClientError('Invalid context: ' . $this->queriedContext);
|
||||
|
||||
}
|
||||
|
||||
$model_json = $this->extractJsonModel($html);
|
||||
$photo_models = $this->getPhotoModels($model_json, $filter);
|
||||
|
||||
foreach($photo_models as $model) {
|
||||
|
||||
$item = array();
|
||||
|
||||
/* Author name depends on scope. On a keyword search the
|
||||
* author is part of the picture data. On a username search
|
||||
* the author is part of the owner data.
|
||||
*/
|
||||
if(array_key_exists('username', $model)) {
|
||||
$item['author'] = $model['username'];
|
||||
} elseif (array_key_exists('owner', reset($model_json)[0])) {
|
||||
$item['author'] = reset($model_json)[0]['owner']['username'];
|
||||
}
|
||||
|
||||
$item['title'] = (array_key_exists('title', $model) ? $model['title'] : 'Untitled');
|
||||
$item['uri'] = self::URI . 'photo.gne?id=' . $model['id'];
|
||||
|
||||
$description = (array_key_exists('description', $model) ? $model['description'] : '');
|
||||
|
||||
$item['content'] = '<a href="'
|
||||
. $item['uri']
|
||||
. '"><img src="'
|
||||
. $this->extractContentImage($model)
|
||||
. '" style="max-width: 640px; max-height: 480px;"/></a><br><p>'
|
||||
. $description
|
||||
. '</p>';
|
||||
|
||||
$item['enclosures'] = $this->extractEnclosures($model);
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function extractJsonModel($html) {
|
||||
|
||||
// Find SCRIPT containing JSON data
|
||||
$model = $html->find('.modelExport', 0);
|
||||
$model_text = $model->innertext;
|
||||
|
||||
// Find start and end of JSON data
|
||||
$start = strpos($model_text, 'modelExport:') + strlen('modelExport:');
|
||||
$end = strpos($model_text, 'auth:') - strlen('auth:');
|
||||
|
||||
// Extract JSON data, remove trailing comma
|
||||
$model_text = trim(substr($model_text, $start, $end - $start));
|
||||
$model_text = substr($model_text, 0, strlen($model_text) - 1);
|
||||
|
||||
return json_decode($model_text, true);
|
||||
|
||||
}
|
||||
|
||||
private function getPhotoModels($json, $filter) {
|
||||
|
||||
// The JSON model contains a "legend" array, where each element contains
|
||||
// the path to an element in the "main" object
|
||||
$photo_models = array();
|
||||
|
||||
foreach($json['legend'] as $legend) {
|
||||
|
||||
$photo_model = $json['main'];
|
||||
|
||||
foreach($legend as $element) { // Traverse tree
|
||||
$photo_model = $photo_model[$element];
|
||||
}
|
||||
|
||||
// We are only interested in content
|
||||
if($photo_model['_flickrModelRegistry'] === $filter) {
|
||||
$photo_models[] = $photo_model;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $photo_models;
|
||||
|
||||
}
|
||||
|
||||
private function extractEnclosures($model) {
|
||||
|
||||
$areas = array();
|
||||
|
||||
foreach($model['sizes'] as $size) {
|
||||
$areas[$size['width'] * $size['height']] = $size['url'];
|
||||
}
|
||||
|
||||
return array($this->fixURL(max($areas)));
|
||||
|
||||
}
|
||||
|
||||
private function extractContentImage($model) {
|
||||
|
||||
$areas = array();
|
||||
$limit = 320 * 240;
|
||||
|
||||
foreach($model['sizes'] as $size) {
|
||||
|
||||
$image_area = $size['width'] * $size['height'];
|
||||
|
||||
if($image_area >= $limit) {
|
||||
$areas[$image_area] = $size['url'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->fixURL(min($areas));
|
||||
|
||||
}
|
||||
|
||||
private function fixURL($url) {
|
||||
|
||||
// For some reason the image URLs don't include the protocol (https)
|
||||
if(strpos($url, '//') === 0) {
|
||||
$url = 'https:' . $url;
|
||||
}
|
||||
|
||||
return $url;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
<?php
|
||||
class FlickrExploreBridge extends BridgeAbstract{
|
||||
|
||||
const MAINTAINER = "sebsauvage";
|
||||
const NAME = "Flickr Explore";
|
||||
const URI = "https://www.flickr.com/";
|
||||
const CACHE_TIMEOUT = 21600; // 6
|
||||
const DESCRIPTION = "Returns the latest interesting images from Flickr";
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM(self::URI.'explore')
|
||||
or returnServerError('Could not request Flickr.');
|
||||
|
||||
foreach($html->find('.photo-list-photo-view') as $element) {
|
||||
// Get the styles
|
||||
$style = explode(';', $element->style);
|
||||
// Get the background-image style
|
||||
$backgroundImage = explode(':', end($style));
|
||||
// URI type : url(//cX.staticflickr.com/X/XXXXX/XXXXXXXXX.jpg)
|
||||
$imageURI = trim(str_replace(['url(', ')'], '', end($backgroundImage)));
|
||||
// Get the image ID
|
||||
$imageURIs = explode('_', basename($imageURI));
|
||||
$imageID = reset($imageURIs);
|
||||
|
||||
// Get the image JSON via Flickr API
|
||||
$imageJSON = json_decode(getContents(
|
||||
'https://api.flickr.com/services/rest/?'
|
||||
.'method=flickr.photos.getInfo&'
|
||||
.'api_key=103b574d49bd51f0e18bfe907da44a0f&'
|
||||
.'photo_id='.$imageID.'&'
|
||||
.'format=json&'
|
||||
.'nojsoncallback=1'
|
||||
)) or returnServerError('Could not request Flickr.'); // FIXME: Request time too long...
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = self::URI.'photo.gne?id='.$imageID;
|
||||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $imageURI . '" /></a>'; // FIXME: Filter javascript ?
|
||||
$item['title'] = $imageJSON->photo->title->_content;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
<?php
|
||||
class FlickrTagBridge extends BridgeAbstract{
|
||||
|
||||
const MAINTAINER = "erwang";
|
||||
const NAME = "Flickr TagUser";
|
||||
const URI = "http://www.flickr.com/";
|
||||
const CACHE_TIMEOUT = 21600; //6h
|
||||
const DESCRIPTION = "Returns the tagged or user images from Flickr";
|
||||
|
||||
const PARAMETERS = array(
|
||||
'By keyword' => array(
|
||||
'q'=>array(
|
||||
'name'=>'keyword',
|
||||
'required'=>true
|
||||
)
|
||||
),
|
||||
|
||||
'By username' => array(
|
||||
'u'=>array(
|
||||
'name'=>'Username',
|
||||
'required'=>true
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
public function collectData(){
|
||||
switch($this->queriedContext){
|
||||
case 'By keyword':
|
||||
$html = getSimpleHTMLDOM(self::URI.'search/?q='.urlencode($this->getInput('q')).'&s=rec')
|
||||
or returnServerError('No results for this query.');
|
||||
break;
|
||||
case 'by username':
|
||||
$html = getSimpleHTMLDOM(self::URI.'photos/'.urlencode($this->getInput('u')).'/')
|
||||
or returnServerError('Requested username can\'t be found.');
|
||||
break;
|
||||
}
|
||||
|
||||
foreach($html->find('span.photo_container') as $element) {
|
||||
$item = array();
|
||||
$item['uri'] = self::URI.$element->find('a',0)->href;
|
||||
$thumbnailUri = $element->find('img',0)->getAttribute('data-defer-src');
|
||||
$item['content'] = '<a href="' . $item['uri'] . '"><img src="' . $thumbnailUri . '" /></a>'; // FIXME: Filter javascript ?
|
||||
$item['title'] = $element->find('a',0)->title;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
class FootitoBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "superbaillot.net";
|
||||
const NAME = "Footito";
|
||||
const URI = "http://www.footito.fr/";
|
||||
const DESCRIPTION = "Footito";
|
||||
const MAINTAINER = 'superbaillot.net';
|
||||
const NAME = 'Footito';
|
||||
const URI = 'http://www.footito.fr/';
|
||||
const DESCRIPTION = 'Footito';
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
@@ -14,15 +14,50 @@ class FootitoBridge extends BridgeAbstract{
|
||||
$item = array();
|
||||
|
||||
$content = trim($element->innertext);
|
||||
$content = str_replace("<img", "<img style='float : left;'", $content );
|
||||
$content = str_replace("class=\"logo\"", "style='float : left;'", $content );
|
||||
$content = str_replace("class=\"contenu\"", "style='margin-left : 60px;'", $content );
|
||||
$content = str_replace("class=\"responsive-comment\"", "style='border-top : 1px #DDD solid; background-color : white; padding : 10px;'", $content );
|
||||
$content = str_replace("class=\"jaime\"", "style='display : none;'", $content );
|
||||
$content = str_replace("class=\"auteur-event responsive\"", "style='display : none;'", $content );
|
||||
$content = str_replace("class=\"report-abuse-button\"", "style='display : none;'", $content );
|
||||
$content = str_replace("class=\"reaction clearfix\"", "style='margin : 10px 0px; padding : 5px; border-bottom : 1px #DDD solid;'", $content );
|
||||
$content = str_replace("class=\"infos\"", "style='font-size : 0.7em;'", $content );
|
||||
$content = str_replace(
|
||||
'<img',
|
||||
"<img style='float : left;'",
|
||||
$content );
|
||||
|
||||
$content = str_replace(
|
||||
'class="logo"',
|
||||
"style='float : left;'",
|
||||
$content );
|
||||
|
||||
$content = str_replace(
|
||||
'class="contenu"',
|
||||
"style='margin-left : 60px;'",
|
||||
$content );
|
||||
|
||||
$content = str_replace(
|
||||
'class="responsive-comment"',
|
||||
"style='border-top : 1px #DDD solid; background-color : white; padding : 10px;'",
|
||||
$content );
|
||||
|
||||
$content = str_replace(
|
||||
'class="jaime"',
|
||||
"style='display : none;'",
|
||||
$content );
|
||||
|
||||
$content = str_replace(
|
||||
'class="auteur-event responsive"',
|
||||
"style='display : none;'",
|
||||
$content );
|
||||
|
||||
$content = str_replace(
|
||||
'class="report-abuse-button"',
|
||||
"style='display : none;'",
|
||||
$content );
|
||||
|
||||
$content = str_replace(
|
||||
'class="reaction clearfix"',
|
||||
"style='margin : 10px 0px; padding : 5px; border-bottom : 1px #DDD solid;'",
|
||||
$content );
|
||||
|
||||
$content = str_replace(
|
||||
'class="infos"',
|
||||
"style='font-size : 0.7em;'",
|
||||
$content );
|
||||
|
||||
$item['content'] = $content;
|
||||
|
||||
|
41
bridges/ForGifsBridge.php
Executable file
41
bridges/ForGifsBridge.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
class ForGifsBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const NAME = 'forgifs Bridge';
|
||||
const URI = 'https://forgifs.com';
|
||||
const DESCRIPTION = 'Returns the forgifs feed with actual gifs instead of images';
|
||||
|
||||
public function collectData() {
|
||||
$this->collectExpandableDatas('https://forgifs.com/gallery/srss/7');
|
||||
}
|
||||
|
||||
protected function parseItem($feedItem) {
|
||||
|
||||
$item = parent::parseItem($feedItem);
|
||||
|
||||
$content = str_get_html($item['content']);
|
||||
$img = $content->find('img', 0);
|
||||
$poster = $img->src;
|
||||
|
||||
// The actual gif is the same path but its id must be decremented by one.
|
||||
// Example:
|
||||
// http://forgifs.com/gallery/d/279419-2/Reporter-videobombed-shoulder-checks.gif
|
||||
// http://forgifs.com/gallery/d/279418-2/Reporter-videobombed-shoulder-checks.gif
|
||||
// Notice how this changes ----------^
|
||||
// Now let's extract that number and do some math
|
||||
// Notice: Technically we could also load the content page but that would
|
||||
// require unnecessary traffic. As long as it works...
|
||||
$num = substr($img->src, 29, 6);
|
||||
$num -= 1;
|
||||
$img->src = substr_replace($img->src, $num, 29, strlen($num));
|
||||
$img->width = 'auto';
|
||||
$img->height = 'auto';
|
||||
|
||||
$item['content'] = $content;
|
||||
|
||||
return $item;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class FourchanBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "4chan";
|
||||
const URI = "https://boards.4chan.org/";
|
||||
const MAINTAINER = 'mitsukarenai';
|
||||
const NAME = '4chan';
|
||||
const URI = 'https://boards.4chan.org/';
|
||||
const CACHE_TIMEOUT = 300; // 5min
|
||||
const DESCRIPTION = "Returns posts from the specified thread";
|
||||
const DESCRIPTION = 'Returns posts from the specified thread';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'c' => array(
|
||||
@@ -20,14 +20,17 @@ class FourchanBridge extends BridgeAbstract{
|
||||
));
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('c')) && !is_null($this->getInput('t'))) {
|
||||
return static::URI . $this->getInput('c') . '/thread/' . $this->getInput('t');
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError("Could not request 4chan, thread not found");
|
||||
or returnServerError('Could not request 4chan, thread not found');
|
||||
|
||||
foreach($html->find('div.postContainer') as $element) {
|
||||
$item = array();
|
||||
@@ -37,12 +40,14 @@ class FourchanBridge extends BridgeAbstract{
|
||||
$item['author'] = $element->find('span.name', 0)->plaintext;
|
||||
|
||||
$file = $element->find('.file', 0);
|
||||
|
||||
if(!empty($file)) {
|
||||
$item['image'] = $element->find('.file a', 0)->href;
|
||||
$item['imageThumb'] = $element->find('.file img', 0)->src;
|
||||
if(!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== FALSE)
|
||||
if(!isset($item['imageThumb']) and strpos($item['image'], '.swf') !== false)
|
||||
$item['imageThumb'] = 'http://i.imgur.com/eO0cxf9.jpg';
|
||||
}
|
||||
|
||||
if(!empty($element->find('span.subject', 0)->innertext)) {
|
||||
$item['subject'] = $element->find('span.subject', 0)->innertext;
|
||||
}
|
||||
@@ -55,10 +60,15 @@ class FourchanBridge extends BridgeAbstract{
|
||||
$content = $element->find('.postMessage', 0)->innertext;
|
||||
$content = str_replace('href="#p', 'href="' . $this->getURI() . '#p', $content);
|
||||
$item['content'] = '<span id="' . $item['id'] . '">' . $content . '</span>';
|
||||
|
||||
if(isset($item['image'])) {
|
||||
$item['content'] = '<a href="'.$item['image'].'">'
|
||||
.'<img alt="'.$item['id'].'" src="'.$item['imageThumb'].'" />'
|
||||
.'</a><br>'
|
||||
$item['content'] = '<a href="'
|
||||
. $item['image']
|
||||
. '"><img alt="'
|
||||
. $item['id']
|
||||
. '" src="'
|
||||
. $item['imageThumb']
|
||||
. '" /></a><br>'
|
||||
.$item['content'];
|
||||
}
|
||||
$this->items[] = $item;
|
||||
|
@@ -88,12 +88,13 @@ class FuturaSciencesBridge extends FeedExpander {
|
||||
$item['uri'] = str_replace('#xtor=RSS-8', '', $item['uri']);
|
||||
$article = getSimpleHTMLDOMCached($item['uri'])
|
||||
or returnServerError('Could not request Futura-Sciences: ' . $item['uri']);
|
||||
$item['content'] = $this->ExtractArticleContent($article);
|
||||
$item['author'] = empty($this->ExtractAuthor($article)) ? $item['author'] : $this->ExtractAuthor($article);
|
||||
$item['content'] = $this->extractArticleContent($article);
|
||||
$author = $this->extractAuthor($article);
|
||||
$item['author'] = empty($author) ? $item['author'] : $author;
|
||||
return $item;
|
||||
}
|
||||
|
||||
function StripWithDelimiters($string, $start, $end) {
|
||||
private function stripWithDelimiters($string, $start, $end){
|
||||
while(strpos($string, $start) !== false) {
|
||||
$section_to_remove = substr($string, strpos($string, $start));
|
||||
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
|
||||
@@ -101,7 +102,7 @@ class FuturaSciencesBridge extends FeedExpander {
|
||||
} return $string;
|
||||
}
|
||||
|
||||
function StripRecursiveHTMLSection($string, $tag_name, $tag_start) {
|
||||
private function stripRecursiveHTMLSection($string, $tag_name, $tag_start){
|
||||
$open_tag = '<' . $tag_name;
|
||||
$close_tag = '</' . $tag_name . '>';
|
||||
$close_tag_length = strlen($close_tag);
|
||||
@@ -125,13 +126,17 @@ class FuturaSciencesBridge extends FeedExpander {
|
||||
return $string;
|
||||
}
|
||||
|
||||
function ExtractArticleContent($article){
|
||||
$contents = $article->find('div.content', 0)->innertext;
|
||||
private function extractArticleContent($article){
|
||||
$contents = $article->find('section.article-text-classic', 0)->innertext;
|
||||
$headline = trim($article->find('p.description', 0)->plaintext);
|
||||
if(!empty($headline))
|
||||
$headline = '<p><b>' . $headline . '</b></p>';
|
||||
|
||||
foreach (array(
|
||||
'<div class="clear',
|
||||
'<div class="sharebar2',
|
||||
'<div class="diaporamafullscreen"',
|
||||
'<div class="module social-button',
|
||||
'<div style="margin-bottom:10px;" class="noprint"',
|
||||
'<div class="ficheprevnext',
|
||||
'<div class="bar noprint',
|
||||
@@ -140,24 +145,26 @@ class FuturaSciencesBridge extends FeedExpander {
|
||||
'<div class="noprint',
|
||||
'<div class="bg bglight border border-full noprint',
|
||||
'<div class="httplogbar-wrapper noprint',
|
||||
'<div id="forumcomments'
|
||||
'<div id="forumcomments',
|
||||
'<div ng-if="active"'
|
||||
) as $div_start) {
|
||||
$contents = $this->StripRecursiveHTMLSection($contents , 'div', $div_start);
|
||||
$contents = $this->stripRecursiveHTMLSection($contents, 'div', $div_start);
|
||||
}
|
||||
|
||||
$contents = $this->StripWithDelimiters($contents, '<hr ', '/>');
|
||||
$contents = $this->StripWithDelimiters($contents, '<p class="content-date', '</p>');
|
||||
$contents = $this->StripWithDelimiters($contents, '<h1 class="content-title', '</h1>');
|
||||
$contents = $this->StripWithDelimiters($contents, 'fs:definition="', '"');
|
||||
$contents = $this->StripWithDelimiters($contents, 'fs:xt:clicktype="', '"');
|
||||
$contents = $this->StripWithDelimiters($contents, 'fs:xt:clickname="', '"');
|
||||
$contents = $this->stripWithDelimiters($contents, '<hr ', '/>');
|
||||
$contents = $this->stripWithDelimiters($contents, '<p class="content-date', '</p>');
|
||||
$contents = $this->stripWithDelimiters($contents, '<h1 class="content-title', '</h1>');
|
||||
$contents = $this->stripWithDelimiters($contents, 'fs:definition="', '"');
|
||||
$contents = $this->stripWithDelimiters($contents, 'fs:xt:clicktype="', '"');
|
||||
$contents = $this->stripWithDelimiters($contents, 'fs:xt:clickname="', '"');
|
||||
$contents = $this->stripWithDelimiters($contents, '<script ', '</script>');
|
||||
|
||||
return $contents;
|
||||
return $headline . trim($contents);
|
||||
}
|
||||
|
||||
// Extracts the author from an article or element
|
||||
function ExtractAuthor($article){
|
||||
$article_author = $article->find('span.author', 0);
|
||||
private function extractAuthor($article){
|
||||
$article_author = $article->find('h3.epsilon', 0);
|
||||
if($article_author) {
|
||||
return trim(str_replace(', Futura-Sciences', '', $article_author->plaintext));
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ class GBAtempBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'ORelio';
|
||||
const NAME = 'GBAtemp';
|
||||
const URI = 'http://gbatemp.net/';
|
||||
const URI = 'https://gbatemp.net/';
|
||||
const DESCRIPTION = 'GBAtemp is a user friendly underground video game community.';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
@@ -20,23 +20,27 @@ class GBAtempBridge extends BridgeAbstract {
|
||||
)
|
||||
));
|
||||
|
||||
private function ExtractFromDelimiters($string, $start, $end) {
|
||||
private function extractFromDelimiters($string, $start, $end){
|
||||
if(strpos($string, $start) !== false) {
|
||||
$section_retrieved = substr($string, strpos($string, $start) + strlen($start));
|
||||
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
|
||||
return $section_retrieved;
|
||||
} return false;
|
||||
}
|
||||
|
||||
private function StripWithDelimiters($string, $start, $end) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private function stripWithDelimiters($string, $start, $end){
|
||||
while(strpos($string, $start) !== false) {
|
||||
$section_to_remove = substr($string, strpos($string, $start));
|
||||
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
|
||||
$string = str_replace($section_to_remove, '', $string);
|
||||
} return $string;
|
||||
}
|
||||
|
||||
private function build_item($uri, $title, $author, $timestamp, $content) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
private function buildItem($uri, $title, $author, $timestamp, $content){
|
||||
$item = array();
|
||||
$item['uri'] = $uri;
|
||||
$item['title'] = $title;
|
||||
@@ -46,21 +50,21 @@ class GBAtempBridge extends BridgeAbstract {
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function cleanup_post_content($content, $site_url) {
|
||||
private function cleanupPostContent($content, $site_url){
|
||||
$content = str_replace(':arrow:', '➤', $content);
|
||||
$content = str_replace('href="attachments/', 'href="'.$site_url.'attachments/', $content);
|
||||
$content = $this->StripWithDelimiters($content, '<script', '</script>');
|
||||
$content = $this->stripWithDelimiters($content, '<script', '</script>');
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function fetch_post_content($uri, $site_url) {
|
||||
private function fetchPostContent($uri, $site_url){
|
||||
$html = getSimpleHTMLDOM($uri);
|
||||
if(!$html) {
|
||||
return 'Could not request GBAtemp ' . $uri;
|
||||
}
|
||||
|
||||
$content = $html->find('div.messageContent', 0)->innertext;
|
||||
return $this->cleanup_post_content($content, $site_url);
|
||||
return $this->cleanupPostContent($content, $site_url);
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
@@ -72,53 +76,82 @@ class GBAtempBridge extends BridgeAbstract {
|
||||
case 'N':
|
||||
foreach($html->find('li[class=news_item full]') as $newsItem) {
|
||||
$url = self::URI . $newsItem->find('a', 0)->href;
|
||||
$time = intval($this->ExtractFromDelimiters($newsItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"'));
|
||||
$time = intval(
|
||||
$this->extractFromDelimiters(
|
||||
$newsItem->find('abbr.DateTime', 0)->outertext,
|
||||
'data-time="',
|
||||
'"'
|
||||
)
|
||||
);
|
||||
$author = $newsItem->find('a.username', 0)->plaintext;
|
||||
$title = $newsItem->find('a', 1)->plaintext;
|
||||
$content = $this->fetch_post_content($url, self::URI);
|
||||
$this->items[] = $this->build_item($url, $title, $author, $time, $content);
|
||||
$content = $this->fetchPostContent($url, self::URI);
|
||||
$this->items[] = $this->buildItem($url, $title, $author, $time, $content);
|
||||
}
|
||||
case 'R':
|
||||
foreach($html->find('li.portal_review') as $reviewItem) {
|
||||
$url = self::URI . $reviewItem->find('a', 0)->href;
|
||||
$title = $reviewItem->find('span.review_title', 0)->plaintext;
|
||||
$content = getSimpleHTMLDOM($url) or returnServerError('Could not request GBAtemp: '.$uri);
|
||||
$content = getSimpleHTMLDOM($url)
|
||||
or returnServerError('Could not request GBAtemp: ' . $uri);
|
||||
$author = $content->find('a.username', 0)->plaintext;
|
||||
$time = intval($this->ExtractFromDelimiters($content->find('abbr.DateTime', 0)->outertext, 'data-time="', '"'));
|
||||
$time = intval(
|
||||
$this->extractFromDelimiters(
|
||||
$content->find('abbr.DateTime', 0)->outertext,
|
||||
'data-time="',
|
||||
'"'
|
||||
)
|
||||
);
|
||||
$intro = '<p><b>' . ($content->find('div#review_intro', 0)->plaintext) . '</b></p>';
|
||||
$review = $content->find('div#review_main', 0)->innertext;
|
||||
$subheader = '<p><b>' . $content->find('div.review_subheader', 0)->plaintext . '</b></p>';
|
||||
$procons = $content->find('table.review_procons', 0)->outertext;
|
||||
$scores = $content->find('table.reviewscores', 0)->outertext;
|
||||
$content = $this->cleanup_post_content($intro.$review.$subheader.$procons.$scores, self::URI);
|
||||
$this->items[] = $this->build_item($url, $title, $author, $time, $content);
|
||||
$content = $this->cleanupPostContent($intro . $review . $subheader . $procons . $scores, self::URI);
|
||||
$this->items[] = $this->buildItem($url, $title, $author, $time, $content);
|
||||
}
|
||||
case 'T':
|
||||
foreach($html->find('li.portal-tutorial') as $tutorialItem) {
|
||||
$url = self::URI . $tutorialItem->find('a', 0)->href;
|
||||
$title = $tutorialItem->find('a', 0)->plaintext;
|
||||
$time = intval($this->ExtractFromDelimiters($tutorialItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"'));
|
||||
$time = intval(
|
||||
$this->extractFromDelimiters(
|
||||
$tutorialItem->find('abbr.DateTime', 0)->outertext,
|
||||
'data-time="',
|
||||
'"'
|
||||
)
|
||||
);
|
||||
$author = $tutorialItem->find('a.username', 0)->plaintext;
|
||||
$content = $this->fetch_post_content($url, self::URI);
|
||||
$this->items[] = $this->build_item($url, $title, $author, $time, $content);
|
||||
$content = $this->fetchPostContent($url, self::URI);
|
||||
$this->items[] = $this->buildItem($url, $title, $author, $time, $content);
|
||||
}
|
||||
case 'F':
|
||||
foreach($html->find('li.rc_item') as $postItem) {
|
||||
$url = self::URI . $postItem->find('a', 1)->href;
|
||||
$title = $postItem->find('a', 1)->plaintext;
|
||||
$time = intval($this->ExtractFromDelimiters($postItem->find('abbr.DateTime', 0)->outertext, 'data-time="', '"'));
|
||||
$time = intval(
|
||||
$this->extractFromDelimiters(
|
||||
$postItem->find('abbr.DateTime', 0)->outertext,
|
||||
'data-time="',
|
||||
'"'
|
||||
)
|
||||
);
|
||||
$author = $postItem->find('a.username', 0)->plaintext;
|
||||
$content = $this->fetch_post_content($url, self::URI);
|
||||
$this->items[] = $this->build_item($url, $title, $author, $time, $content);
|
||||
$content = $this->fetchPostContent($url, self::URI);
|
||||
$this->items[] = $this->buildItem($url, $title, $author, $time, $content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
if(!is_null($this->getInput('type'))) {
|
||||
$type = array_search(
|
||||
$this->getInput('type'),
|
||||
self::PARAMETERS[$this->queriedContext]['type']['values']
|
||||
);
|
||||
return 'GBAtemp ' . $type . ' Bridge';
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
}
|
||||
|
@@ -3,19 +3,33 @@ require_once('DanbooruBridge.php');
|
||||
|
||||
class GelbooruBridge extends DanbooruBridge {
|
||||
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Gelbooru";
|
||||
const URI = "http://gelbooru.com/";
|
||||
const DESCRIPTION = "Returns images from given page";
|
||||
const MAINTAINER = 'mitsukarenai';
|
||||
const NAME = 'Gelbooru';
|
||||
const URI = 'http://gelbooru.com/';
|
||||
const DESCRIPTION = 'Returns images from given page';
|
||||
|
||||
const PATHTODATA = '.thumb';
|
||||
const IDATTRIBUTE = 'id';
|
||||
const TAGATTRIBUTE = 'title';
|
||||
|
||||
const PIDBYPAGE = 63;
|
||||
|
||||
protected function getFullURI(){
|
||||
return $this->getURI().'index.php?page=post&s=list&'
|
||||
.'&pid='.($this->getInput('p')?($this->getInput('p') -1)*static::PIDBYPAGE:'')
|
||||
return $this->getURI()
|
||||
. 'index.php?page=post&s=list&pid='
|
||||
. ($this->getInput('p') ? ($this->getInput('p') - 1) * static::PIDBYPAGE : '')
|
||||
. '&tags=' . urlencode($this->getInput('t'));
|
||||
}
|
||||
|
||||
protected function getTags($element){
|
||||
$tags = parent::getTags($element);
|
||||
$tags = explode(' ', $tags);
|
||||
|
||||
// Remove statistics from the tags list (identified by colon)
|
||||
foreach($tags as $key => $tag) {
|
||||
if(strpos($tag, ':') !== false) unset($tags[$key]);
|
||||
}
|
||||
|
||||
return implode(' ', $tags);
|
||||
}
|
||||
}
|
||||
|
@@ -3,11 +3,11 @@ define('GIPHY_LIMIT', 10);
|
||||
|
||||
class GiphyBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "kraoc";
|
||||
const NAME = "Giphy Bridge";
|
||||
const URI = "http://giphy.com/";
|
||||
const MAINTAINER = 'kraoc';
|
||||
const NAME = 'Giphy Bridge';
|
||||
const URI = 'http://giphy.com/';
|
||||
const CACHE_TIMEOUT = 300; //5min
|
||||
const DESCRIPTION = "Bridge for giphy.com";
|
||||
const DESCRIPTION = 'Bridge for giphy.com';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
's' => array(
|
||||
@@ -58,10 +58,15 @@ class GiphyBridge extends BridgeAbstract{
|
||||
$title = $item['id'];
|
||||
}
|
||||
$item['title'] = trim($title);
|
||||
$item['content'] =
|
||||
'<a href="'.$item['uri'].'">'
|
||||
.'<img src="'.$img->getAttribute('src').'" width="'.$img->getAttribute('data-original-width').'" height="'.$img->getAttribute('data-original-height').'" />'
|
||||
.'</a>';
|
||||
$item['content'] = '<a href="'
|
||||
. $item['uri']
|
||||
. '"><img src="'
|
||||
. $img->getAttribute('src')
|
||||
. '" width="'
|
||||
. $img->getAttribute('data-original-width')
|
||||
. '" height="'
|
||||
. $img->getAttribute('data-original-height')
|
||||
. '" /></a>';
|
||||
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
|
164
bridges/GitHubGistBridge.php
Normal file
164
bridges/GitHubGistBridge.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
class GitHubGistBridge extends BridgeAbstract {
|
||||
|
||||
const NAME = 'GitHubGist comment bridge';
|
||||
const URI = 'https://gist.github.com';
|
||||
const DESCRIPTION = 'Generates feeds for Gist comments';
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const CACHE_TIMEOUT = 3600;
|
||||
|
||||
const PARAMETERS = array(array(
|
||||
'id' => array(
|
||||
'name' => 'Gist',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'title' => 'Insert Gist ID or URI',
|
||||
'exampleValue' => '2646763, https://gist.github.com/2646763'
|
||||
)
|
||||
));
|
||||
|
||||
private $filename;
|
||||
|
||||
public function getURI() {
|
||||
|
||||
$id = $this->getInput('id') ?: '';
|
||||
|
||||
$urlpath = parse_url($id, PHP_URL_PATH);
|
||||
|
||||
if($urlpath) {
|
||||
|
||||
$components = explode('/', $urlpath);
|
||||
$id = end($components);
|
||||
|
||||
}
|
||||
|
||||
return static::URI . '/' . $id;
|
||||
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return $this->filename ? $this->filename . ' - ' . static::NAME : static::NAME;
|
||||
}
|
||||
|
||||
public function collectData() {
|
||||
|
||||
$html = getSimpleHTMLDOM($this->getURI(),
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
DEFAULT_TARGET_CHARSET,
|
||||
false, // Do NOT remove line breaks
|
||||
DEFAULT_BR_TEXT,
|
||||
DEFAULT_SPAN_TEXT)
|
||||
or returnServerError('Could not request ' . $this->getURI());
|
||||
|
||||
$html = defaultLinkTo($html, static::URI);
|
||||
|
||||
$fileinfo = $html->find('[class="file-info"]', 0)
|
||||
or returnServerError('Could not find file info!');
|
||||
|
||||
$this->filename = $fileinfo->plaintext;
|
||||
|
||||
$comments = $html->find('div[class="timeline-comment-wrapper"]');
|
||||
|
||||
if(is_null($comments)) { // no comments yet
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($comments as $comment) {
|
||||
|
||||
$uri = $comment->find('a[href^=#gistcomment]', 0)
|
||||
or returnServerError('Could not find comment anchor!');
|
||||
|
||||
$title = $comment->find('div[class="unminimized-comment"] h3[class="timeline-comment-header-text"]', 0)
|
||||
or returnServerError('Could not find comment header text!');
|
||||
|
||||
$datetime = $comment->find('[datetime]', 0)
|
||||
or returnServerError('Could not find comment datetime!');
|
||||
|
||||
$author = $comment->find('a.author', 0)
|
||||
or returnServerError('Could not find author name!');
|
||||
|
||||
$message = $comment->find('[class="comment-body"]', 0)
|
||||
or returnServerError('Could not find comment body!');
|
||||
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = $this->getURI() . $uri->href;
|
||||
$item['title'] = str_replace('commented', 'commented on', $title->plaintext);
|
||||
$item['timestamp'] = strtotime($datetime->datetime);
|
||||
$item['author'] = '<a href="' . $author->href . '">' . $author->plaintext . '</a>';
|
||||
$item['content'] = $this->fixContent($message);
|
||||
// $item['enclosures'] = array();
|
||||
// $item['categories'] = array();
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Removes all unnecessary tags and adds formatting */
|
||||
private function fixContent($content){
|
||||
|
||||
// Restore code (inside <pre />) highlighting
|
||||
foreach($content->find('pre') as $pre) {
|
||||
|
||||
$pre->style = <<<EOD
|
||||
padding: 16px;
|
||||
overflow: auto;
|
||||
font-size: 85%;
|
||||
line-height: 1.45;
|
||||
background-color: #f6f8fa;
|
||||
border-radius: 3px;
|
||||
word-wrap: normal;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 16px;
|
||||
EOD;
|
||||
|
||||
$code = $pre->find('code', 0);
|
||||
|
||||
if($code) {
|
||||
|
||||
$code->style = <<<EOD
|
||||
white-space: pre;
|
||||
word-break: normal;
|
||||
EOD;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// find <code /> not inside <pre /> (`inline-code`)
|
||||
foreach($content->find('code') as $code) {
|
||||
|
||||
if($code->parent()->tag === 'pre') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$code->style = <<<EOD
|
||||
background-color: rgba(27,31,35,0.05);
|
||||
padding: 0.2em 0.4em;
|
||||
border-radius: 3px;
|
||||
EOD;
|
||||
|
||||
}
|
||||
|
||||
// restore text spacing
|
||||
foreach($content->find('p') as $p) {
|
||||
$p->style = 'margin-bottom: 16px;';
|
||||
}
|
||||
|
||||
// Remove unnecessary tags
|
||||
$content = strip_tags(
|
||||
$content->innertext,
|
||||
'<p><a><img><ol><ul><li><table><tr><th><td><string><pre><code><br><hr><h>'
|
||||
);
|
||||
|
||||
return $content;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -18,7 +18,6 @@ class GithubIssueBridge extends BridgeAbstract{
|
||||
'required' => true
|
||||
)
|
||||
),
|
||||
|
||||
'Project Issues' => array(
|
||||
'c' => array(
|
||||
'name' => 'Show Issues Comments',
|
||||
@@ -48,11 +47,13 @@ class GithubIssueBridge extends BridgeAbstract{
|
||||
case 'Issue comments':
|
||||
$name = static::NAME . ' ' . $name . ' #' . $this->getInput('i');
|
||||
break;
|
||||
default: return parent::getName();
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('u')) && !is_null($this->getInput('p'))) {
|
||||
$uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues';
|
||||
if($this->queriedContext === 'Issue comments') {
|
||||
$uri .= '/' . $this->getInput('i');
|
||||
@@ -62,6 +63,9 @@ class GithubIssueBridge extends BridgeAbstract{
|
||||
return $uri;
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
|
||||
protected function extractIssueComment($issueNbr, $title, $comment){
|
||||
$class = $comment->getAttribute('class');
|
||||
$classes = explode(' ', $class);
|
||||
@@ -75,8 +79,7 @@ class GithubIssueBridge extends BridgeAbstract{
|
||||
$author = $comment->find('.author', 0)->plaintext;
|
||||
}
|
||||
|
||||
$uri=static::URI.$this->getInput('u').'/'.$this->getInput('p').'/issues/'
|
||||
.$issueNbr;
|
||||
$uri = static::URI . $this->getInput('u') . '/' . $this->getInput('p') . '/issues/' . $issueNbr;
|
||||
|
||||
$comment = $comment->firstChild();
|
||||
if(!$event) {
|
||||
@@ -103,7 +106,7 @@ class GithubIssueBridge extends BridgeAbstract{
|
||||
$content = $comment->parent()->innertext;
|
||||
} else {
|
||||
$title .= ' / ' . trim($comment->firstChild()->plaintext);
|
||||
$content="<pre>".$comment->find('.comment-body',0)->innertext."</pre>";
|
||||
$content = '<pre>' . $comment->find('.comment-body', 0)->innertext . '</pre>';
|
||||
}
|
||||
|
||||
$item = array();
|
||||
@@ -122,9 +125,8 @@ class GithubIssueBridge extends BridgeAbstract{
|
||||
$comments = $issue->find('.js-discussion', 0);
|
||||
foreach($comments->children() as $comment) {
|
||||
$classes = explode(' ', $comment->getAttribute('class'));
|
||||
if(in_array('discussion-item',$classes) ||
|
||||
in_array('timeline-comment-wrapper',$classes)
|
||||
){
|
||||
if(in_array('discussion-item', $classes)
|
||||
|| in_array('timeline-comment-wrapper', $classes)) {
|
||||
$item = $this->extractIssueComment($issueNbr, $title, $comment);
|
||||
if(array_keys($item) !== range(0, count($item) - 1)) {
|
||||
$item = array($item);
|
||||
|
50
bridges/GithubSearchBridge.php
Normal file
50
bridges/GithubSearchBridge.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
class GithubSearchBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'corenting';
|
||||
const NAME = 'Github Repositories Search';
|
||||
const URI = 'https://github.com/';
|
||||
const CACHE_TIMEOUT = 600; // 10min
|
||||
const DESCRIPTION = 'Returns a specified repositories search (sorted by recently updated)';
|
||||
const PARAMETERS = array( array(
|
||||
's' => array(
|
||||
'type' => 'text',
|
||||
'name' => 'Search query'
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$params = array('utf8' => '✓',
|
||||
'q' => urlencode($this->getInput('s')),
|
||||
's' => 'updated',
|
||||
'o' => 'desc',
|
||||
'type' => 'Repositories');
|
||||
$url = self::URI . 'search?' . http_build_query($params);
|
||||
|
||||
$html = getSimpleHTMLDOM($url)
|
||||
or returnServerError('Error while downloading the website content');
|
||||
|
||||
foreach($html->find('div.repo-list-item') as $element) {
|
||||
$item = array();
|
||||
|
||||
$uri = $element->find('h3 a', 0)->href;
|
||||
$uri = substr(self::URI, 0, -1) . $uri;
|
||||
$item['uri'] = $uri;
|
||||
|
||||
$title = $element->find('h3', 0)->plaintext;
|
||||
$item['title'] = $title;
|
||||
|
||||
if (count($element->find('p')) == 2) {
|
||||
$content = $element->find('p', 0)->innertext;
|
||||
} else{
|
||||
$content = '';
|
||||
}
|
||||
$item['content'] = $content;
|
||||
|
||||
$date = $element->find('relative-time', 0)->datetime;
|
||||
$item['timestamp'] = strtotime($date);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class GizmodoBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = "polopollo";
|
||||
const NAME = "Gizmodo";
|
||||
const URI = "http://gizmodo.com/";
|
||||
const MAINTAINER = 'polopollo';
|
||||
const NAME = 'Gizmodo';
|
||||
const URI = 'http://gizmodo.com/';
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = "Returns the newest posts from Gizmodo (full text).";
|
||||
const DESCRIPTION = 'Returns the newest posts from Gizmodo (full text).';
|
||||
|
||||
protected function parseItem($item){
|
||||
$item = parent::parseItem($item);
|
||||
@@ -16,7 +16,11 @@ class GizmodoBridge extends FeedExpander {
|
||||
} else {
|
||||
$text = $articleHTMLContent->find('div.entry-content', 0)->innertext;
|
||||
foreach($articleHTMLContent->find('pagespeed_iframe') as $element) {
|
||||
$text .= '<p>link to a iframe (could be a video): <a href="'.$element->src.'">'.$element->src.'</a></p><br>';
|
||||
$text .= '<p>link to a iframe (could be a video): <a href="'
|
||||
. $element->src
|
||||
. '">'
|
||||
. $element->src
|
||||
. '</a></p><br>';
|
||||
}
|
||||
|
||||
$text = strip_tags($text, '<p><b><a><blockquote><img><em>');
|
||||
|
61
bridges/GoComicsBridge.php
Normal file
61
bridges/GoComicsBridge.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
class GoComicsBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'sky';
|
||||
const NAME = 'GoComics Unofficial RSS';
|
||||
const URI = 'https://www.gocomics.com/';
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = 'The Unofficial GoComics RSS';
|
||||
const PARAMETERS = array( array(
|
||||
'comicname' => array(
|
||||
'name' => 'comicname',
|
||||
'type' => 'text',
|
||||
'required' => true
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request GoComics: ' . $this->getURI());
|
||||
|
||||
//Get info from first page
|
||||
$author = preg_replace('/By /', '', $html->find('.media-subheading', 0)->plaintext);
|
||||
|
||||
$link = self::URI . $html->find('.gc-deck--cta-0', 0)->find('a', 0)->href;
|
||||
for($i = 0; $i < 5; $i++) {
|
||||
|
||||
$item = array();
|
||||
|
||||
$page = getSimpleHTMLDOM($link)
|
||||
or returnServerError('Could not request GoComics: ' . $link);
|
||||
$imagelink = $page->find('.img-fluid', 1)->src;
|
||||
$date = explode('/', $link);
|
||||
|
||||
$item['id'] = $imagelink;
|
||||
$item['uri'] = $link;
|
||||
$item['author'] = $author;
|
||||
$item['title'] = 'GoComics ' . $this->getInput('comicname');
|
||||
$item['timestamp'] = DateTime::createFromFormat('Ymd', $date[5] . $date[6] . $date[7])->getTimestamp();
|
||||
$item['content'] = '<img src="' . $imagelink . '" />';
|
||||
|
||||
$link = self::URI . $page->find('.js-previous-comic', 0)->href;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('comicname'))) {
|
||||
return self::URI . urlencode($this->getInput('comicname'));
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('comicname'))) {
|
||||
return $this->getInput('comicname') . ' - GoComics';
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
}
|
@@ -1,113 +1,203 @@
|
||||
<?php
|
||||
class GooglePlusPostBridge extends BridgeAbstract
|
||||
{
|
||||
protected $_title;
|
||||
protected $_url;
|
||||
class GooglePlusPostBridge extends BridgeAbstract{
|
||||
|
||||
const MAINTAINER = "Grummfy";
|
||||
const NAME = "Google Plus Post Bridge";
|
||||
const URI = "https://plus.google.com/";
|
||||
private $title;
|
||||
private $url;
|
||||
|
||||
const MAINTAINER = 'Grummfy, logmanoriginal';
|
||||
const NAME = 'Google Plus Post Bridge';
|
||||
const URI = 'https://plus.google.com';
|
||||
const CACHE_TIMEOUT = 600; //10min
|
||||
const DESCRIPTION = "Returns user public post (without API).";
|
||||
const DESCRIPTION = 'Returns user public post (without API).';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'username' => array(
|
||||
'name' => 'username or Id',
|
||||
'required' => true
|
||||
),
|
||||
'include_media' => array(
|
||||
'name' => 'Include media',
|
||||
'type' => 'checkbox',
|
||||
'title' => 'Enable to include media in the feed content'
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
// get content parsed
|
||||
// $html = getSimpleHTMLDOM(__DIR__ . '/../posts2.html'
|
||||
$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('username')) . '/posts'
|
||||
// force language
|
||||
, false, stream_context_create(array('http'=> array(
|
||||
'header' => 'Accept-Language: fr,fr-be,fr-fr;q=0.8,en;q=0.4,en-us;q=0.2;*' . "\r\n"
|
||||
)))
|
||||
) OR returnServerError('No results for this query.');
|
||||
public function collectData(){
|
||||
|
||||
// get title, url, ... there is a lot of intresting stuff in meta
|
||||
$this->_title = $html->find('meta[property]', 0)->getAttribute('content');
|
||||
$this->_url = $html->find('meta[itemprop=url]', 0)->getAttribute('content');
|
||||
$username = $this->getInput('username');
|
||||
|
||||
// foreach ($html->find('meta') as $e)
|
||||
// {
|
||||
// $item = array();
|
||||
// $item['content'] = var_export($e->attr, true);
|
||||
// $this->items[] = $item;
|
||||
// }
|
||||
// Usernames start with a + if it's not an ID
|
||||
if(!is_numeric($username) && substr($username, 0, 1) !== '+') {
|
||||
$username = '+' . $username;
|
||||
}
|
||||
|
||||
$html = getSimpleHTMLDOM(static::URI . '/' . urlencode($username) . '/posts')
|
||||
or returnServerError('No results for this query.');
|
||||
|
||||
$html = defaultLinkTo($html, static::URI);
|
||||
|
||||
$this->title = $html->find('meta[property=og:title]', 0)->getAttribute('content');
|
||||
$this->url = $html->find('meta[property=og:url]', 0)->getAttribute('content');
|
||||
|
||||
foreach($html->find('div[jsname=WsjYwc]') as $post) {
|
||||
|
||||
// div[jsmodel=XNmfOc]
|
||||
foreach($html->find('div.yt') as $post)
|
||||
{
|
||||
$item = array();
|
||||
// $item['content'] = $post->find('div.Al', 0)->innertext;
|
||||
$item['username'] = $item['fullname'] = $post->find('header.lea h3 a', 0)->innertext;
|
||||
$item['id'] = $post->getAttribute('id');
|
||||
// $item['title'] = $item['fullname'] = $post->find('header.lea', 0)->plaintext;
|
||||
$item['avatar'] = $post->find('div.ys img', 0)->src;
|
||||
// var_dump((($post->find('a.o-U-s', 0)->getAllAttributes())));
|
||||
$item['uri'] = self::URI . $post->find('a.o-U-s', 0)->href;
|
||||
$item['timestamp'] = strtotime($post->find('a.o-U-s', 0)->plaintext);
|
||||
|
||||
$item['author'] = $post->find('div div div div a', 0)->innertext;
|
||||
$item['uri'] = $post->find('div div div a', 1)->href;
|
||||
|
||||
$timestamp = $post->find('a.qXj2He span', 0);
|
||||
|
||||
if($timestamp) {
|
||||
$item['timestamp'] = strtotime('+' . preg_replace(
|
||||
'/[^0-9A-Za-z]/',
|
||||
'',
|
||||
$timestamp->getAttribute('aria-label')));
|
||||
}
|
||||
|
||||
$message = $post->find('div[jsname=EjRJtf]', 0);
|
||||
|
||||
// Empty messages are not supported right now
|
||||
if(!$message) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item['content'] = '<div style="float: left; padding: 0 10px 10px 0;"><a href="'
|
||||
. $this->url
|
||||
. '"><img align="top" alt="'
|
||||
. $item['author']
|
||||
. '" src="'
|
||||
. $post->find('div img', 0)->src
|
||||
. '" /></a></div><div>'
|
||||
. trim(strip_tags($message, '<a><p><div><img>'))
|
||||
. '</div>';
|
||||
|
||||
// Make title at least 50 characters long, but don't add '...' if it is shorter!
|
||||
if(strlen($message->plaintext) > 50) {
|
||||
$end = strpos($message->plaintext, ' ', 50);
|
||||
}
|
||||
|
||||
if(strlen(substr($message->plaintext, 0, $end)) === strlen($message->plaintext)) {
|
||||
$item['title'] = $message->plaintext;
|
||||
} else {
|
||||
$item['title'] = substr($message->plaintext, 0, $end) . '...';
|
||||
}
|
||||
|
||||
$media = $post->find('[jsname="MTOxpb"]', 0);
|
||||
|
||||
if($media) {
|
||||
|
||||
$item['enclosures'] = array();
|
||||
|
||||
foreach($media->find('img') as $img) {
|
||||
$item['enclosures'][] = $this->fixImage($img)->src;
|
||||
}
|
||||
|
||||
if($this->getInput('include_media') === true && count($item['enclosures'] > 0)) {
|
||||
$item['content'] .= '<div style="clear: both;"><a href="'
|
||||
. $item['enclosures'][0]
|
||||
. '"><img src="'
|
||||
. $item['enclosures'][0]
|
||||
. '" /></a></div>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add custom parameters (only useful for JSON or Plaintext)
|
||||
$item['fullname'] = $item['author'];
|
||||
$item['avatar'] = $post->find('div img', 0)->src;
|
||||
$item['id'] = $post->find('div div div', 0)->getAttribute('id');
|
||||
$item['content_simple'] = $message->plaintext;
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
// hashtag to treat : https://plus.google.com/explore/tag
|
||||
$hashtags = array();
|
||||
foreach($post->find('a.d-s') as $hashtag)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return $this->title ?: 'Google Plus Post Bridge';
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
return $this->url ?: parent::getURI();
|
||||
}
|
||||
|
||||
private function fixImage($img) {
|
||||
|
||||
// There are certain images like .gif which link to a static picture and
|
||||
// get replaced dynamically via JS in the browser. If we want the "real"
|
||||
// image we need to account for that.
|
||||
|
||||
$urlparts = parse_url($img->src);
|
||||
|
||||
if(array_key_exists('host', $urlparts)) {
|
||||
|
||||
// For some reason some URIs don't contain the scheme, assume https
|
||||
if(!array_key_exists('scheme', $urlparts)) {
|
||||
$urlparts['scheme'] = 'https';
|
||||
}
|
||||
|
||||
$pathelements = explode('/', $urlparts['path']);
|
||||
|
||||
switch($urlparts['host']) {
|
||||
|
||||
case 'lh3.googleusercontent.com':
|
||||
|
||||
if(pathinfo(end($pathelements), PATHINFO_EXTENSION)) {
|
||||
|
||||
// The second to last element of the path specifies the
|
||||
// image format. The URL is still valid if we remove it.
|
||||
unset($pathelements[count($pathelements) - 2]);
|
||||
|
||||
} elseif(strrpos(end($pathelements), '=') !== false) {
|
||||
|
||||
// Some images go throug a proxy. For those images they
|
||||
// add size information after an equal sign.
|
||||
// Example: '=w530-h298-n'. Again this can safely be
|
||||
// removed to get the original image.
|
||||
$pathelements[count($pathelements) - 1] = substr(
|
||||
end($pathelements),
|
||||
0,
|
||||
strrpos(end($pathelements), '=')
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
$urlparts['path'] = implode('/', $pathelements);
|
||||
|
||||
}
|
||||
|
||||
$img->src = $this->build_url($urlparts);
|
||||
return $img;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* From: https://gist.github.com/Ellrion/f51ba0d40ae1d62eeae44fd1adf7b704
|
||||
* slightly adjusted to work with PHP < 7.0
|
||||
* @param array $parts
|
||||
* @return string
|
||||
*/
|
||||
private function build_url(array $parts)
|
||||
{
|
||||
$hashtags[ trim($hashtag->plaintext) ] = self::URI . $hashtag->href;
|
||||
|
||||
$scheme = isset($parts['scheme']) ? ($parts['scheme'] . '://') : '';
|
||||
$host = isset($parts['host']) ? $parts['host'] : '';
|
||||
$port = isset($parts['port']) ? (':' . $parts['port']) : '';
|
||||
$user = isset($parts['user']) ? $parts['user'] : '';
|
||||
$pass = isset($parts['pass']) ? (':' . $parts['pass']) : '';
|
||||
$pass = ($user || $pass) ? ($pass . '@') : '';
|
||||
$path = isset($parts['path']) ? $parts['path'] : '';
|
||||
$query = isset($parts['query']) ? ('?' . $parts['query']) : '';
|
||||
$fragment = isset($parts['fragment']) ? ('#' . $parts['fragment']) : '';
|
||||
|
||||
return implode('', [$scheme, $user, $pass, $host, $port, $path, $query, $fragment]);
|
||||
|
||||
}
|
||||
|
||||
$item['content'] = '';
|
||||
|
||||
// avatar display
|
||||
$item['content'] .= '<div style="float:left; margin: 0 0.5em 0.5em 0;"><a href="' . self::URI . urlencode($this->getInput('username'));
|
||||
$item['content'] .= '"><img align="top" alt="avatar" src="' . $item['avatar'].'" />' . $item['username'] . '</a></div>';
|
||||
|
||||
$content = $post->find('div.Al', 0);
|
||||
|
||||
// alter link
|
||||
// $content = $content->innertext;
|
||||
// $content = str_replace('href="./', 'href="' . self::URI, $content);
|
||||
// $content = str_replace('href="photos', 'href="' . self::URI . 'photos', $content);
|
||||
// XXX ugly but I don't have any idea how to do a better stuff, str_replace on link doesn't work as expected and ask too many checks
|
||||
foreach($content->find('a') as $link)
|
||||
{
|
||||
$hasHttp = strpos($link->href, 'http');
|
||||
$hasDoubleSlash = strpos($link->href, '//');
|
||||
|
||||
if ((!$hasHttp && !$hasDoubleSlash)
|
||||
|| (false !== $hasHttp && strpos($link->href, 'http') != 0)
|
||||
|| (false === $hasHttp && false !== $hasDoubleSlash && $hasDoubleSlash != 0))
|
||||
{
|
||||
// skipp bad link, for some hashtag or other stuff
|
||||
if (strpos($link->href, '/') == 0)
|
||||
{
|
||||
$link->href = substr($link->href, 1);
|
||||
}
|
||||
$link->href = self::URI . $link->href;
|
||||
}
|
||||
}
|
||||
$content = $content->innertext;
|
||||
|
||||
$item['content'] .= '<div style="margin-top: -1.5em">' . $content . '</div>';
|
||||
|
||||
// extract plaintext
|
||||
$item['content_simple'] = $post->find('div.Al', 0)->plaintext;
|
||||
}
|
||||
|
||||
// $html->save(__DIR__ . '/../posts2.html');
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->_title ?: 'Google Plus Post Bridge';
|
||||
}
|
||||
|
||||
public function getURI()
|
||||
{
|
||||
return $this->_url ?: self::URI;
|
||||
}
|
||||
}
|
||||
|
@@ -9,46 +9,56 @@
|
||||
*/
|
||||
class GoogleSearchBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "sebsauvage";
|
||||
const NAME = "Google search";
|
||||
const URI = "https://www.google.com/";
|
||||
const MAINTAINER = 'sebsauvage';
|
||||
const NAME = 'Google search';
|
||||
const URI = 'https://www.google.com/';
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = "Returns most recent results from Google search.";
|
||||
const DESCRIPTION = 'Returns most recent results from Google search.';
|
||||
|
||||
const PARAMETERS = array(array(
|
||||
'q' => array(
|
||||
'name'=>"keyword",
|
||||
'name' => 'keyword',
|
||||
'required' => true
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
public function collectData(){
|
||||
$html = '';
|
||||
|
||||
$html = getSimpleHTMLDOM(self::URI
|
||||
.'search?q=' . urlencode($this->getInput('q'))
|
||||
. 'search?q='
|
||||
. urlencode($this->getInput('q'))
|
||||
.'&num=100&complete=0&tbs=qdr:y,sbd:1')
|
||||
or returnServerError('No results for this query.');
|
||||
|
||||
$emIsRes = $html->find('div[id=ires]', 0);
|
||||
|
||||
if(!is_null($emIsRes)) {
|
||||
foreach($emIsRes->find('li[class=g]') as $element) {
|
||||
foreach($emIsRes->find('div[class=g]') as $element) {
|
||||
|
||||
$item = array();
|
||||
|
||||
// Extract direct URL from google href (eg. /url?q=...)
|
||||
$t = $element->find('a[href]', 0)->href;
|
||||
$item['uri'] = '' . $t;
|
||||
parse_str(parse_url($t, PHP_URL_QUERY), $parameters);
|
||||
if (isset($parameters['q'])) { $item['uri'] = $parameters['q']; }
|
||||
if(isset($parameters['q'])) {
|
||||
$item['uri'] = $parameters['q'];
|
||||
}
|
||||
|
||||
$item['title'] = $element->find('h3', 0)->plaintext;
|
||||
$item['content'] = $element->find('span[class=st]', 0)->plaintext;
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('q'))) {
|
||||
return $this->getInput('q') . ' - Google search';
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
}
|
||||
|
61
bridges/GrandComicsDatabaseBridge.php
Normal file
61
bridges/GrandComicsDatabaseBridge.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
class GrandComicsDatabaseBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'corenting';
|
||||
const NAME = 'Grand Comics Database Bridge';
|
||||
const URI = 'https://www.comics.org/';
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = 'Returns the latest comics added to a series timeline';
|
||||
const PARAMETERS = array( array(
|
||||
'series' => array(
|
||||
'name' => 'Series id (from the timeline URL)',
|
||||
'required' => true,
|
||||
'exampleValue' => '63051',
|
||||
),
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$url = self::URI . 'series/' . $this->getInput('series') . '/details/timeline/';
|
||||
$html = getSimpleHTMLDOM($url)
|
||||
or returnServerError('Error while downloading the website content');
|
||||
|
||||
$table = $html->find('table', 0);
|
||||
$list = array_reverse($table->find('[class^=row_even]'));
|
||||
$seriesName = $html->find('span[id=series_name]', 0)->innertext;
|
||||
|
||||
// Get row headers
|
||||
$rowHeaders = $table->find('th');
|
||||
foreach($list as $article) {
|
||||
|
||||
// Skip empty rows
|
||||
$emptyRow = $article->find('td.empty_month');
|
||||
if (count($emptyRow) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$rows = $article->find('td');
|
||||
$key_date = $rows[0]->innertext;
|
||||
|
||||
// Get URL too
|
||||
$uri = 'https://www.comics.org' . $article->find('a')[0]->href;
|
||||
|
||||
// Build content
|
||||
$content = '';
|
||||
for($i = 0; $i < count($rowHeaders); $i++) {
|
||||
$headerItem = $rowHeaders[$i]->innertext;
|
||||
$rowItem = $rows[$i]->innertext;
|
||||
$content = $content . $headerItem . ': ' . $rowItem . '<br/>';
|
||||
}
|
||||
|
||||
// Build final item
|
||||
$item = array();
|
||||
$item['title'] = $seriesName . ' - ' . $key_date;
|
||||
$item['timestamp'] = strtotime($key_date);
|
||||
$item['content'] = str_get_html($content);
|
||||
$item['uri'] = $uri;
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +1,19 @@
|
||||
<?php
|
||||
class HDWallpapersBridge extends BridgeAbstract {
|
||||
const MAINTAINER = "nel50n";
|
||||
const NAME = "HD Wallpapers Bridge";
|
||||
const URI = "http://www.hdwallpapers.in/";
|
||||
const MAINTAINER = 'nel50n';
|
||||
const NAME = 'HD Wallpapers Bridge';
|
||||
const URI = 'http://www.hdwallpapers.in/';
|
||||
const CACHE_TIMEOUT = 43200; //12h
|
||||
const DESCRIPTION = "Returns the latests wallpapers from HDWallpapers";
|
||||
const DESCRIPTION = 'Returns the latests wallpapers from HDWallpapers';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'c' => array(
|
||||
'name' => 'category',
|
||||
'defaultValue' => 'latest_wallpapers'
|
||||
),
|
||||
'm'=>array('name'=>'max number of wallpapers'),
|
||||
'm' => array(
|
||||
'name' => 'max number of wallpapers'
|
||||
),
|
||||
'r' => array(
|
||||
'name' => 'resolution',
|
||||
'defaultValue' => '1920x1200',
|
||||
@@ -31,7 +33,8 @@ class HDWallpapersBridge extends BridgeAbstract {
|
||||
|
||||
for($page = 1; $page <= $lastpage; $page++) {
|
||||
$link = self::URI . '/' . $category . '/page/' . $page;
|
||||
$html = getSimpleHTMLDOM($link) or returnServerError('No results for this query.');
|
||||
$html = getSimpleHTMLDOM($link)
|
||||
or returnServerError('No results for this query.');
|
||||
|
||||
if($page === 1) {
|
||||
preg_match('/page\/(\d+)$/', $html->find('.pagination a', -2)->href, $matches);
|
||||
@@ -43,10 +46,20 @@ class HDWallpapersBridge extends BridgeAbstract {
|
||||
|
||||
$item = array();
|
||||
// http://www.hdwallpapers.in/download/yosemite_reflections-1680x1050.jpg
|
||||
$item['uri'] = self::URI.'/download'.str_replace('wallpapers.html', $this->getInput('r').'.jpg', $element->href);
|
||||
$item['uri'] = self::URI
|
||||
. '/download'
|
||||
. str_replace('wallpapers.html', $this->getInput('r') . '.jpg', $element->href);
|
||||
|
||||
$item['timestamp'] = time();
|
||||
$item['title'] = $element->find('p', 0)->text();
|
||||
$item['content'] = $item['title'].'<br><a href="'.$item['uri'].'"><img src="'.self::URI.$thumbnail->src.'" /></a>';
|
||||
$item['content'] = $item['title']
|
||||
. '<br><a href="'
|
||||
. $item['uri']
|
||||
. '"><img src="'
|
||||
. self::URI
|
||||
. $thumbnail->src
|
||||
. '" /></a>';
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
$num++;
|
||||
@@ -57,6 +70,14 @@ class HDWallpapersBridge extends BridgeAbstract {
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
return 'HDWallpapers - '.str_replace(['__', '_'], [' & ', ' '], $this->getInput('c')).' ['.$this->getInput('r').']';
|
||||
if(!is_null($this->getInput('c')) && !is_null($this->getInput('r'))) {
|
||||
return 'HDWallpapers - '
|
||||
. str_replace(['__', '_'], [' & ', ' '], $this->getInput('c'))
|
||||
. ' ['
|
||||
. $this->getInput('r')
|
||||
. ']';
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
}
|
||||
|
@@ -1,22 +1,36 @@
|
||||
<?php
|
||||
class HentaiHavenBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "albirew";
|
||||
const NAME = "Hentai Haven";
|
||||
const URI = "http://hentaihaven.org/";
|
||||
const MAINTAINER = 'albirew';
|
||||
const NAME = 'Hentai Haven';
|
||||
const URI = 'http://hentaihaven.org/';
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = "Returns releases from Hentai Haven";
|
||||
const DESCRIPTION = 'Returns releases from Hentai Haven';
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or returnServerError('Could not request Hentai Haven.');
|
||||
|
||||
foreach($html->find('div.zoe-grid') as $element) {
|
||||
$item = array();
|
||||
$item['uri'] = $element->find('div.brick-content h3 a', 0)->href;
|
||||
$thumbnailUri = $element->find('a.thumbnail-image img', 0)->getAttribute('data-src');
|
||||
$item['title'] = mb_convert_encoding(trim($element->find('div.brick-content h3 a', 0)->innertext), 'UTF-8', 'HTML-ENTITIES');
|
||||
$item['title'] = mb_convert_encoding(
|
||||
trim($element->find('div.brick-content h3 a', 0)->innertext),
|
||||
'UTF-8',
|
||||
'HTML-ENTITIES'
|
||||
);
|
||||
|
||||
$item['tags'] = $element->find('div.oFlyout_bg div.oFlyout div.flyoutContent span.tags', 0)->plaintext;
|
||||
$item['content'] = 'Tags: ' . $item['tags'].'<br><br><a href="' . $item['uri'] . '"><img width="300" height="169" src="' . $thumbnailUri . '" /></a><br>' . $element->find('div.oFlyout_bg div.oFlyout div.flyoutContent p.description', 0)->innertext;
|
||||
$item['content'] = 'Tags: '
|
||||
. $item['tags']
|
||||
. '<br><br><a href="'
|
||||
. $item['uri']
|
||||
. '"><img width="300" height="169" src="'
|
||||
. $thumbnailUri
|
||||
. '" /></a><br>'
|
||||
. $element->find('div.oFlyout_bg div.oFlyout div.flyoutContent p.description', 0)->innertext;
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
1397
bridges/HotUKDealsBridge.php
Normal file
1397
bridges/HotUKDealsBridge.php
Normal file
File diff suppressed because it is too large
Load Diff
310
bridges/IPBBridge.php
Normal file
310
bridges/IPBBridge.php
Normal file
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
class IPBBridge extends FeedExpander {
|
||||
|
||||
const NAME = 'IPB Bridge';
|
||||
const URI = 'https://www.invisionpower.com';
|
||||
const DESCRIPTION = 'Returns feeds for forums powered by IPB';
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const PARAMETERS = array(
|
||||
array(
|
||||
'uri' => array(
|
||||
'name' => 'URI',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'title' => 'Insert forum, subforum or topic URI',
|
||||
'exampleValue' => 'https://invisioncommunity.com/forums/forum/499-feedback-and-ideas/'
|
||||
),
|
||||
'limit' => array(
|
||||
'name' => 'Limit',
|
||||
'type' => 'number',
|
||||
'required' => false,
|
||||
'title' => 'Specifies the number of items to return on each request (-1: all)',
|
||||
'defaultValue' => 10
|
||||
)
|
||||
)
|
||||
);
|
||||
const CACHE_TIMEOUT = 3600;
|
||||
|
||||
// Constants for internal use
|
||||
const FORUM_TYPE_LIST_FILTER = '.cForumTopicTable';
|
||||
const FORUM_TYPE_TABLE_FILTER = '#forum_table';
|
||||
|
||||
const TOPIC_TYPE_ARTICLE = 'article';
|
||||
const TOPIC_TYPE_DIV = 'div.post_block';
|
||||
|
||||
public function getURI(){
|
||||
return $this->getInput('uri') ?: parent::getURI();
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
// The URI cannot be the mainpage (or anything related)
|
||||
switch(parse_url($this->getInput('uri'), PHP_URL_PATH)) {
|
||||
case null:
|
||||
case '/index.php':
|
||||
returnClientError('Provided URI is invalid!');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Sanitize the URI (because else it won't work)
|
||||
$uri = rtrim($this->getInput('uri'), '/'); // No trailing slashes!
|
||||
|
||||
// Forums might provide feeds, though that's optional *facepalm*
|
||||
// Let's check if there is a valid feed available
|
||||
$headers = get_headers($uri . '.xml');
|
||||
|
||||
if($headers[0] === 'HTTP/1.1 200 OK') { // Heureka! It's a valid feed!
|
||||
return $this->collectExpandableDatas($uri);
|
||||
}
|
||||
|
||||
// No valid feed, so do it the hard way
|
||||
$html = getSimpleHTMLDOM($uri)
|
||||
or returnServerError('Could not request ' . $this->getInput('uri') . '!');
|
||||
|
||||
$limit = $this->getInput('limit');
|
||||
|
||||
// Determine if this is a topic or a forum
|
||||
switch(true) {
|
||||
case $this->isTopic($html):
|
||||
$this->collectTopic($html, $limit);
|
||||
break;
|
||||
case $this->isForum($html);
|
||||
$this->collectForum($html);
|
||||
break;
|
||||
default:
|
||||
returnClientError('Unknown type!');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function isForum($html){
|
||||
return !is_null($html->find('div[data-controller*=forums.front.forum.forumPage]', 0))
|
||||
|| !is_null($html->find(static::FORUM_TYPE_TABLE_FILTER, 0));
|
||||
}
|
||||
|
||||
private function isTopic($html){
|
||||
return !is_null($html->find('div[data-controller*=core.front.core.commentFeed]', 0))
|
||||
|| !is_null($html->find(static::TOPIC_TYPE_DIV, 0));
|
||||
}
|
||||
|
||||
private function collectForum($html){
|
||||
// There are multiple forum designs in use (depends on version?)
|
||||
// 1 - Uses an ordered list (based on https://invisioncommunity.com/forums)
|
||||
// 2 - Uses a table (based on https://onehallyu.com)
|
||||
|
||||
switch(true) {
|
||||
case !is_null($html->find(static::FORUM_TYPE_LIST_FILTER, 0)):
|
||||
$this->collectForumList($html);
|
||||
break;
|
||||
case !is_null($html->find(static::FORUM_TYPE_TABLE_FILTER, 0)):
|
||||
$this->collectForumTable($html);
|
||||
break;
|
||||
default:
|
||||
returnClientError('Unknown forum format!');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function collectForumList($html){
|
||||
foreach($html->find(static::FORUM_TYPE_LIST_FILTER, 0)->children() as $row) {
|
||||
// Columns: Title, Statistics, Last modified
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = $row->find('a', 0)->href;
|
||||
$item['title'] = $row->find('a', 0)->title;
|
||||
$item['author'] = $row->find('a', 1)->innertext;
|
||||
$item['timestamp'] = strtotime($row->find('time', 0)->getAttribute('datetime'));
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function collectForumTable($html){
|
||||
foreach($html->find(static::FORUM_TYPE_TABLE_FILTER, 0)->children() as $row) {
|
||||
// Columns: Icon, Content, Preview, Statistics, Last modified
|
||||
$item = array();
|
||||
|
||||
// Skip header row
|
||||
if(!is_null($row->find('th', 0))) continue;
|
||||
|
||||
$item['uri'] = $row->find('a', 0)->href;
|
||||
$item['title'] = $row->find('.title', 0)->plaintext;
|
||||
$item['timestamp'] = strtotime($row->find('[itemprop=dateCreated]', 0)->plaintext);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function collectTopic($html, $limit){
|
||||
// There are multiple topic designs in use (depends on version?)
|
||||
// 1 - Uses articles (based on https://invisioncommunity.com/forums)
|
||||
// 2 - Uses divs (based on https://onehallyu.com)
|
||||
|
||||
switch(true) {
|
||||
case !is_null($html->find(static::TOPIC_TYPE_ARTICLE, 0)):
|
||||
$this->collectTopicHistory($html, $limit, 'collectTopicArticle');
|
||||
break;
|
||||
case !is_null($html->find(static::TOPIC_TYPE_DIV, 0)):
|
||||
$this->collectTopicHistory($html, $limit, 'collectTopicDiv');
|
||||
break;
|
||||
default:
|
||||
returnClientError('Unknown topic format!');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function collectTopicHistory($html, $limit, $callback){
|
||||
// Make sure the callback is valid!
|
||||
if(!method_exists($this, $callback))
|
||||
returnServerError('Unknown function (\'' . $callback . '\')!');
|
||||
|
||||
$next = null; // Holds the URI of the next page
|
||||
|
||||
while(true) {
|
||||
$next = $this->$callback($html, is_null($next));
|
||||
|
||||
if(is_null($next) || ($limit > 0 && count($this->items) >= $limit)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$html = getSimpleHTMLDOMCached($next);
|
||||
}
|
||||
|
||||
// We might have more items than specified, remove excess
|
||||
$this->items = array_slice($this->items, 0, $limit);
|
||||
}
|
||||
|
||||
private function collectTopicArticle($html, $firstrun = true){
|
||||
$title = $html->find('h1.ipsType_pageTitle', 0)->plaintext;
|
||||
|
||||
// Are we on last page?
|
||||
if($firstrun && !is_null($html->find('.ipsPagination', 0))) {
|
||||
$last = $html->find('.ipsPagination_last a', 0)->{'data-page'};
|
||||
$active = $html->find('.ipsPagination_active a', 0)->{'data-page'};
|
||||
|
||||
if($active !== $last) {
|
||||
// Load last page into memory (cached)
|
||||
$html = getSimpleHTMLDOMCached($html->find('.ipsPagination_last a', 0)->href);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(array_reverse($html->find(static::TOPIC_TYPE_ARTICLE)) as $article) {
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = $article->find('time', 0)->parent()->href;
|
||||
$item['author'] = $article->find('aside a', 0)->plaintext;
|
||||
$item['title'] = $item['author'] . ' - ' . $title;
|
||||
$item['timestamp'] = strtotime($article->find('time', 0)->getAttribute('datetime'));
|
||||
|
||||
$content = $article->find('[data-role=commentContent]', 0);
|
||||
$content = $this->scaleImages($content);
|
||||
$item['content'] = $this->fixContent($content);
|
||||
$item['enclosures'] = $this->findImages($article->find('[data-role=commentContent]', 0)) ?: null;
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
// Return whatever page comes next (previous, as we add in inverse order)
|
||||
// Do we have a previous page? (inactive means no)
|
||||
if(!is_null($html->find('li[class=ipsPagination_prev ipsPagination_inactive]', 0))) {
|
||||
return null; // No, or no more
|
||||
} elseif(!is_null($html->find('li[class=ipsPagination_prev]', 0))) {
|
||||
return $html->find('.ipsPagination_prev a', 0)->href;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function collectTopicDiv($html, $firstrun = true){
|
||||
$title = $html->find('h1.ipsType_pagetitle', 0)->plaintext;
|
||||
|
||||
// Are we on last page?
|
||||
if($firstrun && !is_null($html->find('.pagination', 0))) {
|
||||
|
||||
$active = $html->find('li[class=page active]', 0)->plaintext;
|
||||
|
||||
// There are two ways the 'last' page is displayed:
|
||||
// - With a distict 'last' button (only if there are enough pages)
|
||||
// - With a button for each page (use last button)
|
||||
if(!is_null($html->find('li.last', 0))) {
|
||||
$last = $html->find('li.last a', 0);
|
||||
} else {
|
||||
$last = $html->find('li[class=page] a', -1);
|
||||
}
|
||||
|
||||
if($active !== $last->plaintext) {
|
||||
// Load last page into memory (cached)
|
||||
$html = getSimpleHTMLDOMCached($last->href);
|
||||
}
|
||||
}
|
||||
|
||||
foreach(array_reverse($html->find(static::TOPIC_TYPE_DIV)) as $article) {
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = $article->find('a[rel=bookmark]', 0)->href;
|
||||
$item['author'] = $article->find('.author', 0)->plaintext;
|
||||
$item['title'] = $item['author'] . ' - ' . $title;
|
||||
$item['timestamp'] = strtotime($article->find('.published', 0)->getAttribute('title'));
|
||||
|
||||
$content = $article->find('[itemprop=commentText]', 0);
|
||||
$content = $this->scaleImages($content);
|
||||
$item['content'] = $this->fixContent($content);
|
||||
|
||||
$item['enclosures'] = $this->findImages($article->find('.post_body', 0)) ?: null;
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
// Return whatever page comes next (previous, as we add in inverse order)
|
||||
// Do we have a previous page?
|
||||
if(!is_null($html->find('li.prev', 0))) {
|
||||
return $html->find('li.prev a', 0)->href;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Returns all images from the provide HTML DOM */
|
||||
private function findImages($html){
|
||||
$images = array();
|
||||
|
||||
foreach($html->find('img') as $img) {
|
||||
$images[] = $img->src;
|
||||
}
|
||||
|
||||
return $images;
|
||||
}
|
||||
|
||||
/** Sets the maximum width and height for all images */
|
||||
private function scaleImages($html, $width = 400, $height = 400){
|
||||
foreach($html->find('img') as $img) {
|
||||
$img->style = "max-width: {$width}px; max-height: {$height}px;";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/** Removes all unnecessary tags and adds formatting */
|
||||
private function fixContent($html){
|
||||
|
||||
// Restore quote highlighting
|
||||
foreach($html->find('blockquote') as $quote) {
|
||||
$quote->style = <<<EOD
|
||||
padding: 0px 15px;
|
||||
border-width: 1px 1px 1px 2px;
|
||||
border-style: solid;
|
||||
border-color: #ededed #e8e8e8 #dbdbdb #666666;
|
||||
background: #fbfbfb;
|
||||
EOD;
|
||||
}
|
||||
|
||||
// Remove unnecessary tags
|
||||
$content = strip_tags(
|
||||
$html->innertext,
|
||||
'<p><a><img><ol><ul><li><table><tr><th><td><strong><blockquote><br><hr><h>'
|
||||
);
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class IdenticaBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Identica Bridge";
|
||||
const URI = "https://identi.ca/";
|
||||
const MAINTAINER = 'mitsukarenai';
|
||||
const NAME = 'Identica Bridge';
|
||||
const URI = 'https://identi.ca/';
|
||||
const CACHE_TIMEOUT = 300; // 5min
|
||||
const DESCRIPTION = "Returns user timelines";
|
||||
const DESCRIPTION = 'Returns user timelines';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'u' => array(
|
||||
@@ -20,19 +20,33 @@ class IdenticaBridge extends BridgeAbstract{
|
||||
|
||||
foreach($html->find('li.major') as $dent) {
|
||||
$item = array();
|
||||
$item['uri'] = html_entity_decode($dent->find('a', 0)->href); // get dent link
|
||||
$item['timestamp'] = strtotime($dent->find('abbr.easydate', 0)->plaintext); // extract dent timestamp
|
||||
$item['content'] = trim($dent->find('div.activity-content', 0)->innertext); // extract dent text
|
||||
|
||||
// get dent link
|
||||
$item['uri'] = html_entity_decode($dent->find('a', 0)->href);
|
||||
|
||||
// extract dent timestamp
|
||||
$item['timestamp'] = strtotime($dent->find('abbr.easydate', 0)->plaintext);
|
||||
|
||||
// extract dent text
|
||||
$item['content'] = trim($dent->find('div.activity-content', 0)->innertext);
|
||||
$item['title'] = $this->getInput('u') . ' | ' . $item['content'];
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('u'))) {
|
||||
return $this->getInput('u') . ' - Identica Bridge';
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('u'))) {
|
||||
return self::URI . urlencode($this->getInput('u'));
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
}
|
||||
|
@@ -1,71 +1,149 @@
|
||||
<?php
|
||||
class InstagramBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "pauder";
|
||||
const NAME = "Instagram Bridge";
|
||||
const URI = "http://instagram.com/";
|
||||
const DESCRIPTION = "Returns the newest images";
|
||||
const MAINTAINER = 'pauder';
|
||||
const NAME = 'Instagram Bridge';
|
||||
const URI = 'https://instagram.com/';
|
||||
const DESCRIPTION = 'Returns the newest images';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
const PARAMETERS = array(
|
||||
array(
|
||||
'u' => array(
|
||||
'name' => 'username',
|
||||
'required' => true
|
||||
)
|
||||
));
|
||||
),
|
||||
array(
|
||||
'h' => array(
|
||||
'name' => 'hashtag',
|
||||
'required' => true
|
||||
)
|
||||
),
|
||||
'global' => array(
|
||||
'media_type' => array(
|
||||
'name' => 'Media type',
|
||||
'type' => 'list',
|
||||
'required' => false,
|
||||
'values' => array(
|
||||
'All' => 'all',
|
||||
'Story' => 'story',
|
||||
'Video' => 'video',
|
||||
'Picture' => 'picture',
|
||||
),
|
||||
'defaultValue' => 'all'
|
||||
)
|
||||
)
|
||||
|
||||
);
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request Instagram.');
|
||||
|
||||
$innertext = null;
|
||||
|
||||
foreach($html->find('script') as $script)
|
||||
{
|
||||
if ('' === $script->innertext) {
|
||||
continue;
|
||||
if(!is_null($this->getInput('h')) && $this->getInput('media_type') == 'story') {
|
||||
returnClientError('Stories are not supported for hashtags!');
|
||||
}
|
||||
|
||||
$pos = strpos(trim($script->innertext), 'window._sharedData');
|
||||
if (0 !== $pos)
|
||||
{
|
||||
continue;
|
||||
$data = $this->getInstagramJSON($this->getURI());
|
||||
|
||||
if(!is_null($this->getInput('u'))) {
|
||||
$userMedia = $data->entry_data->ProfilePage[0]->graphql->user->edge_owner_to_timeline_media->edges;
|
||||
} else {
|
||||
$userMedia = $data->entry_data->TagPage[0]->graphql->hashtag->edge_hashtag_to_media->edges;
|
||||
}
|
||||
|
||||
$innertext = $script->innertext;
|
||||
foreach($userMedia as $media) {
|
||||
$media = $media->node;
|
||||
|
||||
if(!is_null($this->getInput('u'))) {
|
||||
switch($this->getInput('media_type')) {
|
||||
case 'all': break;
|
||||
case 'video':
|
||||
if($media->__typename != 'GraphVideo') continue 2;
|
||||
break;
|
||||
case 'picture':
|
||||
if($media->__typename != 'GraphImage') continue 2;
|
||||
break;
|
||||
case 'story':
|
||||
if($media->__typename != 'GraphSidecar') continue 2;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
} else {
|
||||
if($this->getInput('media_type') == 'video' && !$media->is_video) continue;
|
||||
}
|
||||
|
||||
$json = trim(substr($innertext, $pos+18), ' =;');
|
||||
$data = json_decode($json);
|
||||
|
||||
|
||||
|
||||
$userMedia = $data->entry_data->ProfilePage[0]->user->media->nodes;
|
||||
|
||||
foreach($userMedia as $media)
|
||||
{
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = self::URI.'p/'.$media->code.'/';
|
||||
$item['content'] = '<img src="' . htmlentities($media->display_src) . '" />';
|
||||
if (isset($media->caption))
|
||||
{
|
||||
$item['title'] = $media->caption;
|
||||
$item['uri'] = self::URI . 'p/' . $media->shortcode . '/';
|
||||
|
||||
if (isset($media->edge_media_to_caption->edges[0]->node->text)) {
|
||||
$item['title'] = $media->edge_media_to_caption->edges[0]->node->text;
|
||||
} else {
|
||||
$item['title'] = basename($media->display_src);
|
||||
$item['title'] = basename($media->display_url);
|
||||
}
|
||||
$item['timestamp'] = $media->date;
|
||||
|
||||
if(!is_null($this->getInput('u')) && $media->__typename == 'GraphSidecar') {
|
||||
$data = $this->getInstagramStory($item['uri']);
|
||||
$item['content'] = $data[0];
|
||||
$item['enclosures'] = $data[1];
|
||||
} else {
|
||||
$item['content'] = '<img src="' . htmlentities($media->display_url) . '" alt="'. $item['title'] . '" />';
|
||||
$item['enclosures'] = array($media->display_url);
|
||||
}
|
||||
|
||||
$item['timestamp'] = $media->taken_at_timestamp;
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
protected function getInstagramStory($uri) {
|
||||
|
||||
$data = $this->getInstagramJSON($uri);
|
||||
$mediaInfo = $data->entry_data->PostPage[0]->graphql->shortcode_media;
|
||||
|
||||
//Process the first element, that isn't in the node graph
|
||||
$caption = $mediaInfo->edge_media_to_caption->edges[0]->node->text;
|
||||
|
||||
$enclosures = [$mediaInfo->display_url];
|
||||
$content = '<img src="' . htmlentities($mediaInfo->display_url) . '" alt="'. $caption . '" />';
|
||||
|
||||
foreach($mediaInfo->edge_sidecar_to_children->edges as $media) {
|
||||
|
||||
$content .= '<img src="' . htmlentities($media->node->display_url) . '" alt="'. $caption . '" />';
|
||||
$enclosures[] = $media->node->display_url;
|
||||
|
||||
}
|
||||
|
||||
return [$content, $enclosures];
|
||||
|
||||
}
|
||||
|
||||
protected function getInstagramJSON($uri) {
|
||||
|
||||
$html = getContents($uri)
|
||||
or returnServerError('Could not request Instagram.');
|
||||
$scriptRegex = '/window\._sharedData = (.*);<\/script>/';
|
||||
|
||||
preg_match($scriptRegex, $html, $matches, PREG_OFFSET_CAPTURE, 0);
|
||||
|
||||
return json_decode($matches[1][0]);
|
||||
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('u'))) {
|
||||
return $this->getInput('u') . ' - Instagram Bridge';
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
return self::URI.urlencode($this->getInput('u'));
|
||||
}
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('u'))) {
|
||||
return self::URI . urlencode($this->getInput('u'));
|
||||
} elseif(!is_null($this->getInput('h'))) {
|
||||
return self::URI . 'explore/tags/' . urlencode($this->getInput('h'));
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
}
|
||||
|
370
bridges/InstructablesBridge.php
Normal file
370
bridges/InstructablesBridge.php
Normal file
@@ -0,0 +1,370 @@
|
||||
<?php
|
||||
/**
|
||||
* This class implements a bridge for http://www.instructables.com, supporting
|
||||
* general feeds and feeds by category. Instructables doesn't support HTTPS as
|
||||
* of now (23.06.2018), so all connections are insecure!
|
||||
*
|
||||
* Remarks:
|
||||
* - For some reason it is very important to have the category URI end with a
|
||||
* slash, otherwise the site defaults to the main category (i.e. Technology)!
|
||||
* If you need to update the categories list, enable the 'listCategories'
|
||||
* function (see comments below) and run the bridge with format=Html (see page
|
||||
* source)
|
||||
*/
|
||||
class InstructablesBridge extends BridgeAbstract {
|
||||
const NAME = 'Instructables Bridge';
|
||||
const URI = 'http://www.instructables.com';
|
||||
const DESCRIPTION = 'Returns general feeds and feeds by category';
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const PARAMETERS = array(
|
||||
'Category' => array(
|
||||
'category' => array(
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'required' => true,
|
||||
'values' => array(
|
||||
'Play' => array(
|
||||
'All' => '/play/',
|
||||
'KNEX' => '/play/knex/',
|
||||
'Offbeat' => '/play/offbeat/',
|
||||
'Lego' => '/play/lego/',
|
||||
'Airsoft' => '/play/airsoft/',
|
||||
'Card Games' => '/play/card-games/',
|
||||
'Guitars' => '/play/guitars/',
|
||||
'Instruments' => '/play/instruments/',
|
||||
'Magic Tricks' => '/play/magic-tricks/',
|
||||
'Minecraft' => '/play/minecraft/',
|
||||
'Music' => '/play/music/',
|
||||
'Nerf' => '/play/nerf/',
|
||||
'Nintendo' => '/play/nintendo/',
|
||||
'Office Supplies' => '/play/office-supplies/',
|
||||
'Paintball' => '/play/paintball/',
|
||||
'Paper Airplanes' => '/play/paper-airplanes/',
|
||||
'Party Tricks' => '/play/party-tricks/',
|
||||
'PlayStation' => '/play/playstation/',
|
||||
'Pranks and Humor' => '/play/pranks-and-humor/',
|
||||
'Puzzles' => '/play/puzzles/',
|
||||
'Siege Engines' => '/play/siege-engines/',
|
||||
'Sports' => '/play/sports/',
|
||||
'Table Top' => '/play/table-top/',
|
||||
'Toys' => '/play/toys/',
|
||||
'Video Games' => '/play/video-games/',
|
||||
'Wii' => '/play/wii/',
|
||||
'Xbox' => '/play/xbox/',
|
||||
'Yo-Yo' => '/play/yo-yo/',
|
||||
),
|
||||
'Craft' => array(
|
||||
'All' => '/craft/',
|
||||
'Art' => '/craft/art/',
|
||||
'Sewing' => '/craft/sewing/',
|
||||
'Paper' => '/craft/paper/',
|
||||
'Jewelry' => '/craft/jewelry/',
|
||||
'Fashion' => '/craft/fashion/',
|
||||
'Books & Journals' => '/craft/books-and-journals/',
|
||||
'Cards' => '/craft/cards/',
|
||||
'Clay' => '/craft/clay/',
|
||||
'Duct Tape' => '/craft/duct-tape/',
|
||||
'Embroidery' => '/craft/embroidery/',
|
||||
'Felt' => '/craft/felt/',
|
||||
'Fiber Arts' => '/craft/fiber-arts/',
|
||||
'Gifts & Wrapping' => '/craft/gifts-and-wrapping/',
|
||||
'Knitting & Crocheting' => '/craft/knitting-and-crocheting/',
|
||||
'Leather' => '/craft/leather/',
|
||||
'Mason Jars' => '/craft/mason-jars/',
|
||||
'No-Sew' => '/craft/no-sew/',
|
||||
'Parties & Weddings' => '/craft/parties-and-weddings/',
|
||||
'Print Making' => '/craft/print-making/',
|
||||
'Soap' => '/craft/soap/',
|
||||
'Wallets' => '/craft/wallets/',
|
||||
),
|
||||
'Technology' => array(
|
||||
'All' => '/technology/',
|
||||
'Electronics' => '/technology/electronics/',
|
||||
'Arduino' => '/technology/arduino/',
|
||||
'Photography' => '/technology/photography/',
|
||||
'Leds' => '/technology/leds/',
|
||||
'Science' => '/technology/science/',
|
||||
'Reuse' => '/technology/reuse/',
|
||||
'Apple' => '/technology/apple/',
|
||||
'Computers' => '/technology/computers/',
|
||||
'3D Printing' => '/technology/3D-Printing/',
|
||||
'Robots' => '/technology/robots/',
|
||||
'Art' => '/technology/art/',
|
||||
'Assistive Tech' => '/technology/assistive-technology/',
|
||||
'Audio' => '/technology/audio/',
|
||||
'Clocks' => '/technology/clocks/',
|
||||
'CNC' => '/technology/cnc/',
|
||||
'Digital Graphics' => '/technology/digital-graphics/',
|
||||
'Gadgets' => '/technology/gadgets/',
|
||||
'Kits' => '/technology/kits/',
|
||||
'Laptops' => '/technology/laptops/',
|
||||
'Lasers' => '/technology/lasers/',
|
||||
'Linux' => '/technology/linux/',
|
||||
'Microcontrollers' => '/technology/microcontrollers/',
|
||||
'Microsoft' => '/technology/microsoft/',
|
||||
'Mobile' => '/technology/mobile/',
|
||||
'Raspberry Pi' => '/technology/raspberry-pi/',
|
||||
'Remote Control' => '/technology/remote-control/',
|
||||
'Sensors' => '/technology/sensors/',
|
||||
'Software' => '/technology/software/',
|
||||
'Soldering' => '/technology/soldering/',
|
||||
'Speakers' => '/technology/speakers/',
|
||||
'Steampunk' => '/technology/steampunk/',
|
||||
'Tools' => '/technology/tools/',
|
||||
'USB' => '/technology/usb/',
|
||||
'Wearables' => '/technology/wearables/',
|
||||
'Websites' => '/technology/websites/',
|
||||
'Wireless' => '/technology/wireless/',
|
||||
),
|
||||
'Workshop' => array(
|
||||
'All' => '/workshop/',
|
||||
'Woodworking' => '/workshop/woodworking/',
|
||||
'Tools' => '/workshop/tools/',
|
||||
'Gardening' => '/workshop/gardening/',
|
||||
'Cars' => '/workshop/cars/',
|
||||
'Metalworking' => '/workshop/metalworking/',
|
||||
'Cardboard' => '/workshop/cardboard/',
|
||||
'Electric Vehicles' => '/workshop/electric-vehicles/',
|
||||
'Energy' => '/workshop/energy/',
|
||||
'Furniture' => '/workshop/furniture/',
|
||||
'Home Improvement' => '/workshop/home-improvement/',
|
||||
'Home Theater' => '/workshop/home-theater/',
|
||||
'Hydroponics' => '/workshop/hydroponics/',
|
||||
'Laser Cutting' => '/workshop/laser-cutting/',
|
||||
'Lighting' => '/workshop/lighting/',
|
||||
'Molds & Casting' => '/workshop/molds-and-casting/',
|
||||
'Motorcycles' => '/workshop/motorcycles/',
|
||||
'Organizing' => '/workshop/organizing/',
|
||||
'Pallets' => '/workshop/pallets/',
|
||||
'Repair' => '/workshop/repair/',
|
||||
'Shelves' => '/workshop/shelves/',
|
||||
'Solar' => '/workshop/solar/',
|
||||
'Workbenches' => '/workshop/workbenches/',
|
||||
),
|
||||
'Home' => array(
|
||||
'All' => '/home/',
|
||||
'Halloween' => '/home/halloween/',
|
||||
'Decorating' => '/home/decorating/',
|
||||
'Organizing' => '/home/organizing/',
|
||||
'Pets' => '/home/pets/',
|
||||
'Life Hacks' => '/home/life-hacks/',
|
||||
'Beauty' => '/home/beauty/',
|
||||
'Christmas' => '/home/christmas/',
|
||||
'Cleaning' => '/home/cleaning/',
|
||||
'Education' => '/home/education/',
|
||||
'Finances' => '/home/finances/',
|
||||
'Gardening' => '/home/gardening/',
|
||||
'Green' => '/home/green/',
|
||||
'Health' => '/home/health/',
|
||||
'Hiding Places' => '/home/hiding-places/',
|
||||
'Holidays' => '/home/holidays/',
|
||||
'Homesteading' => '/home/homesteading/',
|
||||
'Kids' => '/home/kids/',
|
||||
'Kitchen' => '/home/kitchen/',
|
||||
'Life Skills' => '/home/life-skills/',
|
||||
'Parenting' => '/home/parenting/',
|
||||
'Pest Control' => '/home/pest-control/',
|
||||
'Relationships' => '/home/relationships/',
|
||||
'Reuse' => '/home/reuse/',
|
||||
'Travel' => '/home/travel/',
|
||||
),
|
||||
'Outside' => array(
|
||||
'All' => '/outside/',
|
||||
'Bikes' => '/outside/bikes/',
|
||||
'Survival' => '/outside/survival/',
|
||||
'Backyard' => '/outside/backyard/',
|
||||
'Beach' => '/outside/beach/',
|
||||
'Birding' => '/outside/birding/',
|
||||
'Boats' => '/outside/boats/',
|
||||
'Camping' => '/outside/camping/',
|
||||
'Climbing' => '/outside/climbing/',
|
||||
'Fire' => '/outside/fire/',
|
||||
'Fishing' => '/outside/fishing/',
|
||||
'Hunting' => '/outside/hunting/',
|
||||
'Kites' => '/outside/kites/',
|
||||
'Knives' => '/outside/knives/',
|
||||
'Knots' => '/outside/knots/',
|
||||
'Paracord' => '/outside/paracord/',
|
||||
'Rockets' => '/outside/rockets/',
|
||||
'Skateboarding' => '/outside/skateboarding/',
|
||||
'Snow' => '/outside/snow/',
|
||||
'Water' => '/outside/water/',
|
||||
),
|
||||
'Food' => array(
|
||||
'All' => '/food/',
|
||||
'Dessert' => '/food/dessert/',
|
||||
'Snacks & Appetizers' => '/food/snacks-and-appetizers/',
|
||||
'Bacon' => '/food/bacon/',
|
||||
'BBQ & Grilling' => '/food/bbq-and-grilling/',
|
||||
'Beverages' => '/food/beverages/',
|
||||
'Bread' => '/food/bread/',
|
||||
'Breakfast' => '/food/breakfast/',
|
||||
'Cake' => '/food/cake/',
|
||||
'Candy' => '/food/candy/',
|
||||
'Canning & Preserves' => '/food/canning-and-preserves/',
|
||||
'Cocktails & Mocktails' => '/food/cocktails-and-mocktails/',
|
||||
'Coffee' => '/food/coffee/',
|
||||
'Cookies' => '/food/cookies/',
|
||||
'Cupcakes' => '/food/cupcakes/',
|
||||
'Homebrew' => '/food/homebrew/',
|
||||
'Main Course' => '/food/main-course/',
|
||||
'Pasta' => '/food/pasta/',
|
||||
'Pie' => '/food/pie/',
|
||||
'Pizza' => '/food/pizza/',
|
||||
'Salad' => '/food/salad/',
|
||||
'Sandwiches' => '/food/sandwiches/',
|
||||
'Soups & Stews' => '/food/soups-and-stews/',
|
||||
'Vegetarian & Vegan' => '/food/vegetarian-and-vegan/',
|
||||
),
|
||||
'Costumes' => array(
|
||||
'All' => '/costumes/',
|
||||
'Props' => '/costumes/props-and-accessories/',
|
||||
'Animals' => '/costumes/animals/',
|
||||
'Comics' => '/costumes/comics/',
|
||||
'Fantasy' => '/costumes/fantasy/',
|
||||
'For Kids' => '/costumes/for-kids/',
|
||||
'For Pets' => '/costumes/for-pets/',
|
||||
'Funny' => '/costumes/funny/',
|
||||
'Games' => '/costumes/games/',
|
||||
'Historic & Futuristic' => '/costumes/historic-and-futuristic/',
|
||||
'Makeup' => '/costumes/makeup/',
|
||||
'Masks' => '/costumes/masks/',
|
||||
'Scary' => '/costumes/scary/',
|
||||
'TV & Movies' => '/costumes/tv-and-movies/',
|
||||
'Weapons & Armor' => '/costumes/weapons-and-armor/',
|
||||
)
|
||||
),
|
||||
'title' => 'Select your category (required)',
|
||||
'defaultValue' => 'Technology'
|
||||
),
|
||||
'filter' => array(
|
||||
'name' => 'Filter',
|
||||
'type' => 'list',
|
||||
'required' => true,
|
||||
'values' => array(
|
||||
'Featured' => ' ',
|
||||
'Recent' => 'recent/',
|
||||
'Popular' => 'popular/',
|
||||
'Views' => 'views/',
|
||||
'Contest Winners' => 'winners/'
|
||||
),
|
||||
'title' => 'Select a filter',
|
||||
'defaultValue' => 'Featured'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
private $uri;
|
||||
|
||||
public function collectData() {
|
||||
// Enable the following line to get the category list (dev mode)
|
||||
// $this->listCategories();
|
||||
|
||||
$this->uri = static::URI;
|
||||
|
||||
switch($this->queriedContext) {
|
||||
case 'Category': $this->uri .= $this->getInput('category') . $this->getInput('filter');
|
||||
}
|
||||
|
||||
$html = getSimpleHTMLDOM($this->uri)
|
||||
or returnServerError('Error loading category ' . $this->uri);
|
||||
|
||||
foreach($html->find('ul.explore-covers-list li') as $cover) {
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = static::URI . $cover->find('a.cover-image', 0)->href;
|
||||
$item['title'] = $cover->find('.title', 0)->innertext;
|
||||
$item['author'] = $this->getCategoryAuthor($cover);
|
||||
$item['content'] = '<a href='
|
||||
. $item['uri']
|
||||
. '><img src='
|
||||
. $cover->find('a.cover-image img', 0)->src
|
||||
. '></a>';
|
||||
|
||||
$image = str_replace('.RECTANGLE1', '.LARGE', $cover->find('a.cover-image img', 0)->src);
|
||||
$item['enclosures'] = [$image];
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
if(!is_null($this->getInput('category'))
|
||||
&& !is_null($this->getInput('filter'))) {
|
||||
foreach(self::PARAMETERS[$this->queriedContext]['category']['values'] as $key => $value) {
|
||||
$subcategory = array_search($this->getInput('category'), $value);
|
||||
|
||||
if($subcategory !== false)
|
||||
break;
|
||||
}
|
||||
|
||||
$filter = array_search(
|
||||
$this->getInput('filter'),
|
||||
self::PARAMETERS[$this->queriedContext]['filter']['values']
|
||||
);
|
||||
|
||||
return $subcategory . ' (' . $filter . ') - ' . static::NAME;
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function getURI() {
|
||||
if(!is_null($this->getInput('category'))
|
||||
&& !is_null($this->getInput('filter'))) {
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of categories for development purposes (used to build the
|
||||
* parameters list)
|
||||
*/
|
||||
private function listCategories(){
|
||||
// Use arbitrary category to receive full list
|
||||
$html = getSimpleHTMLDOM(self::URI . '/technology/');
|
||||
|
||||
foreach($html->find('.channel a') as $channel) {
|
||||
$name = html_entity_decode(trim($channel->innertext));
|
||||
|
||||
// Remove unwanted entities
|
||||
$name = str_replace("'", '', $name);
|
||||
$name = str_replace(''', '', $name);
|
||||
|
||||
$uri = $channel->href;
|
||||
|
||||
$category = explode('/', $uri)[1];
|
||||
|
||||
if(!isset($categories)
|
||||
|| !array_key_exists($category, $categories)
|
||||
|| !in_array($uri, $categories[$category]))
|
||||
$categories[$category][$name] = $uri;
|
||||
}
|
||||
|
||||
// Build PHP array manually
|
||||
foreach($categories as $key => $value) {
|
||||
$name = ucfirst($key);
|
||||
echo "'{$name}' => array(\n";
|
||||
echo "\t'All' => '/{$key}/',\n";
|
||||
foreach($value as $name => $uri) {
|
||||
echo "\t'{$name}' => '{$uri}',\n";
|
||||
}
|
||||
echo "),\n";
|
||||
}
|
||||
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the author as anchor for a given cover.
|
||||
*/
|
||||
private function getCategoryAuthor($cover) {
|
||||
return '<a href='
|
||||
. static::URI . $cover->find('span.author a', 0)->href
|
||||
. '>'
|
||||
. $cover->find('span.author a', 0)->innertext
|
||||
. '</a>';
|
||||
}
|
||||
}
|
@@ -1,468 +0,0 @@
|
||||
<?php
|
||||
class IsoHuntBridge extends BridgeAbstract{
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const NAME = 'isoHunt Bridge';
|
||||
const URI = 'https://isohunt.to/';
|
||||
const CACHE_TIMEOUT = 300; //5min
|
||||
const DESCRIPTION = 'Returns the latest results by category or search result';
|
||||
|
||||
const PARAMETERS = array(
|
||||
/*
|
||||
* Get feeds for one of the "latest" categories
|
||||
* Notice: The categories "News" and "Top Searches" are received from the main page
|
||||
* Elements are sorted by name ascending!
|
||||
*/
|
||||
'By "Latest" category' => array(
|
||||
'latest_category'=>array(
|
||||
'name'=>'Latest category',
|
||||
'type'=>'list',
|
||||
'required'=>true,
|
||||
'title'=>'Select your category',
|
||||
'defaultValue'=>'news',
|
||||
'values'=>array(
|
||||
'Hot Torrents'=>'hot_torrents',
|
||||
'News'=>'news',
|
||||
'Releases'=>'releases',
|
||||
'Torrents'=>'torrents'
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
* Get feeds for one of the "torrent" categories
|
||||
* Make sure to add new categories also to get_torrent_category_index($)!
|
||||
* Elements are sorted by name ascending!
|
||||
*/
|
||||
'By "Torrent" category' => array(
|
||||
'torrent_category'=>array(
|
||||
'name'=>'Torrent category',
|
||||
'type'=>'list',
|
||||
'required'=>true,
|
||||
'title'=>'Select your category',
|
||||
'defaultValue'=>'anime',
|
||||
'values'=>array(
|
||||
'Adult'=>'adult',
|
||||
'Anime'=>'anime',
|
||||
'Books'=>'books',
|
||||
'Games'=>'games',
|
||||
'Movies'=>'movies',
|
||||
'Music'=>'music',
|
||||
'Other'=>'other',
|
||||
'Series & TV'=>'series_tv',
|
||||
'Software'=>'software'
|
||||
)
|
||||
),
|
||||
'torrent_popularity'=>array(
|
||||
'name'=>'Sort by popularity',
|
||||
'type'=>'checkbox',
|
||||
'title'=>'Activate to receive results by popularity'
|
||||
)
|
||||
),
|
||||
|
||||
/*
|
||||
* Get feeds for a specific search request
|
||||
*/
|
||||
'Search torrent by name' => array(
|
||||
'search_name'=>array(
|
||||
'name'=>'Name',
|
||||
'required'=>true,
|
||||
'title'=>'Insert your search query',
|
||||
'exampleValue'=>'Bridge'
|
||||
),
|
||||
'search_category'=>array(
|
||||
'name'=>'Category',
|
||||
'type'=>'list',
|
||||
'title'=>'Select your category',
|
||||
'defaultValue'=>'all',
|
||||
'values'=>array(
|
||||
'Adult'=>'adult',
|
||||
'All'=>'all',
|
||||
'Anime'=>'anime',
|
||||
'Books'=>'books',
|
||||
'Games'=>'games',
|
||||
'Movies'=>'movies',
|
||||
'Music'=>'music',
|
||||
'Other'=>'other',
|
||||
'Series & TV'=>'series_tv',
|
||||
'Software'=>'software'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function getURI(){
|
||||
$uri=self::URI;
|
||||
switch($this->queriedContext){
|
||||
case 'By "Latest" category':
|
||||
switch($this->getInput('latest_category')){
|
||||
case 'hot_torrents':
|
||||
$uri .= 'statistic/hot/torrents';
|
||||
break;
|
||||
case 'news':
|
||||
break;
|
||||
case 'releases':
|
||||
$uri .= 'releases.php';
|
||||
break;
|
||||
case 'torrents':
|
||||
$uri .= 'latest.php';
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'By "Torrent" category':
|
||||
$uri .= $this->build_category_uri(
|
||||
$this->getInput('torrent_category'),
|
||||
$this->getInput('torrent_popularity')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'Search torrent by name':
|
||||
$category=$this->getInput('search_category');
|
||||
$uri .= $this->build_category_uri($category);
|
||||
if($category!=='movies')
|
||||
$uri .= '&ihq=' . urlencode($this->getInput('search_name'));
|
||||
break;
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
switch($this->queriedContext){
|
||||
case 'By "Latest" category':
|
||||
$categoryName =
|
||||
array_search(
|
||||
$this->getInput('latest_category'),
|
||||
self::PARAMETERS['By "Latest" category']['latest_category']['values']
|
||||
);
|
||||
$name = 'Latest '.$categoryName.' - ' . self::NAME;
|
||||
break;
|
||||
|
||||
case 'By "Torrent" category':
|
||||
$categoryName =
|
||||
array_search(
|
||||
$this->getInput('torrent_category'),
|
||||
self::PARAMETERS['By "Torrent" category']['torrent_category']['values']
|
||||
);
|
||||
$name = 'Category: ' . $categoryName . ' - ' . self::NAME;
|
||||
break;
|
||||
|
||||
case 'Search torrent by name':
|
||||
$categoryName =
|
||||
array_search(
|
||||
$this->getInput('search_category'),
|
||||
self::PARAMETERS['Search torrent by name']['search_category']['values']
|
||||
);
|
||||
$name = 'Search: "' . $this->getInput('search_name') . '" in category: ' . $categoryName . ' - ' . self::NAME;
|
||||
break;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
|
||||
public function collectData(){
|
||||
$html = $this->load_html($this->getURI());
|
||||
|
||||
switch($this->queriedContext){
|
||||
case 'By "Latest" category':
|
||||
switch($this->getInput('latest_category')){
|
||||
case 'hot_torrents':
|
||||
$this->get_latest_hot_torrents($html);
|
||||
break;
|
||||
case 'news':
|
||||
$this->get_latest_news($html);
|
||||
break;
|
||||
case 'releases':
|
||||
case 'torrents':
|
||||
$this->get_latest_torrents($html);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'By "Torrent" category':
|
||||
if($this->getInput('torrent_category') === 'movies'){
|
||||
// This one is special (content wise)
|
||||
$this->get_movie_torrents($html);
|
||||
}else{
|
||||
$this->get_latest_torrents($html);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Search torrent by name':
|
||||
if( $this->getInput('search_category') === 'movies'){
|
||||
// This one is special (content wise)
|
||||
$this->get_movie_torrents($html);
|
||||
} else {
|
||||
$this->get_latest_torrents($html);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#region Helper functions for "Movie Torrents"
|
||||
|
||||
private function get_movie_torrents($html){
|
||||
$container = $html->find('div#w0', 0);
|
||||
if(!$container)
|
||||
returnServerError('Unable to find torrent container!');
|
||||
|
||||
$torrents = $container->find('article');
|
||||
if(!$torrents)
|
||||
returnServerError('Unable to find torrents!');
|
||||
|
||||
foreach($torrents as $torrent){
|
||||
|
||||
$anchor = $torrent->find('a', 0);
|
||||
if(!$anchor)
|
||||
returnServerError('Unable to find anchor!');
|
||||
|
||||
$date = $torrent->find('small', 0);
|
||||
if(!$date)
|
||||
returnServerError('Unable to find date!');
|
||||
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = $this->fix_relative_uri($anchor->href);
|
||||
$item['title'] = $anchor->title;
|
||||
// $item['author'] =
|
||||
$item['timestamp'] = strtotime($date->plaintext);
|
||||
$item['content'] = $this->fix_relative_uri($torrent->innertext);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper functions for "Latest Hot Torrents"
|
||||
|
||||
private function get_latest_hot_torrents($html){
|
||||
$container = $html->find('div#serps', 0);
|
||||
if(!$container)
|
||||
returnServerError('Unable to find torrent container!');
|
||||
|
||||
$torrents = $container->find('tr');
|
||||
if(!$torrents)
|
||||
returnServerError('Unable to find torrents!');
|
||||
|
||||
// Remove first element (header row)
|
||||
$torrents = array_slice($torrents, 1);
|
||||
|
||||
foreach($torrents as $torrent){
|
||||
|
||||
$cell = $torrent->find('td', 0);
|
||||
if(!$cell)
|
||||
returnServerError('Unable to find cell!');
|
||||
|
||||
$element = $cell->find('a', 0);
|
||||
if(!$element)
|
||||
returnServerError('Unable to find element!');
|
||||
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = $element->href;
|
||||
$item['title'] = $element->plaintext;
|
||||
// $item['author'] =
|
||||
// $item['timestamp'] =
|
||||
// $item['content'] =
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper functions for "Latest News"
|
||||
|
||||
private function get_latest_news($html){
|
||||
$container = $html->find('div#postcontainer', 0);
|
||||
if(!$container)
|
||||
returnServerError('Unable to find post container!');
|
||||
|
||||
$posts = $container->find('div.index-post');
|
||||
if(!$posts)
|
||||
returnServerError('Unable to find posts!');
|
||||
|
||||
foreach($posts as $post){
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = $this->latest_news_extract_uri($post);
|
||||
$item['title'] = $this->latest_news_extract_title($post);
|
||||
$item['author'] = $this->latest_news_extract_author($post);
|
||||
$item['timestamp'] = $this->latest_news_extract_timestamp($post);
|
||||
$item['content'] = $this->latest_news_extract_content($post);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function latest_news_extract_author($post){
|
||||
$author = $post->find('small', 0);
|
||||
if(!$author)
|
||||
returnServerError('Unable to find author!');
|
||||
|
||||
// The author is hidden within a string like: 'Posted by {author} on {date}'
|
||||
preg_match('/Posted\sby\s(.*)\son/i', $author->innertext, $matches);
|
||||
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
private function latest_news_extract_timestamp($post){
|
||||
$date = $post->find('small', 0);
|
||||
if(!$date)
|
||||
returnServerError('Unable to find date!');
|
||||
|
||||
// The date is hidden within a string like: 'Posted by {author} on {date}'
|
||||
preg_match('/Posted\sby\s.*\son\s(.*)/i', $date->innertext, $matches);
|
||||
|
||||
$timestamp = strtotime($matches[1]);
|
||||
|
||||
// Make sure date is not in the future (dates are given like 'Nov. 20' without year)
|
||||
if($timestamp > time()){
|
||||
$timestamp = strtotime('-1 year', $timestamp);
|
||||
}
|
||||
|
||||
return $timestamp;
|
||||
}
|
||||
|
||||
private function latest_news_extract_title($post){
|
||||
$title = $post->find('a', 0);
|
||||
if(!$title)
|
||||
returnServerError('Unable to find title!');
|
||||
|
||||
return $title->plaintext;
|
||||
}
|
||||
|
||||
private function latest_news_extract_uri($post){
|
||||
$uri = $post->find('a', 0);
|
||||
if(!$uri)
|
||||
returnServerError('Unable to find uri!');
|
||||
|
||||
return $uri->href;
|
||||
}
|
||||
|
||||
private function latest_news_extract_content($post){
|
||||
$content = $post->find('div', 0);
|
||||
if(!$content)
|
||||
returnServerError('Unable to find content!');
|
||||
|
||||
// Remove <h2>...</h2> (title)
|
||||
foreach($content->find('h2') as $element){
|
||||
$element->outertext = '';
|
||||
}
|
||||
|
||||
// Remove <small>...</small> (author)
|
||||
foreach($content->find('small') as $element){
|
||||
$element->outertext = '';
|
||||
}
|
||||
|
||||
return $content->innertext;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Helper functions for "Latest Torrents", "Latest Releases" and "Torrent Category"
|
||||
|
||||
private function get_latest_torrents($html){
|
||||
$container = $html->find('div#serps', 0);
|
||||
if(!$container)
|
||||
returnServerError('Unable to find torrent container!');
|
||||
|
||||
$torrents = $container->find('tr[data-key]');
|
||||
if(!$torrents)
|
||||
returnServerError('Unable to find torrents!');
|
||||
|
||||
foreach($torrents as $torrent){
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = $this->latest_torrents_extract_uri($torrent);
|
||||
$item['title'] = $this->latest_torrents_extract_title($torrent);
|
||||
$item['author'] = $this->latest_torrents_extract_author($torrent);
|
||||
$item['timestamp'] = $this->latest_torrents_extract_timestamp($torrent);
|
||||
$item['content'] = ''; // There is no valuable content
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function latest_torrents_extract_title($torrent){
|
||||
$cell = $torrent->find('td.title-row', 0);
|
||||
if(!$cell)
|
||||
returnServerError('Unable to find title cell!');
|
||||
|
||||
$title = $cell->find('span', 0);
|
||||
if(!$title)
|
||||
returnServerError('Unable to find title!');
|
||||
|
||||
return $title->plaintext;
|
||||
}
|
||||
|
||||
private function latest_torrents_extract_uri($torrent){
|
||||
$cell = $torrent->find('td.title-row', 0);
|
||||
if(!$cell)
|
||||
returnServerError('Unable to find title cell!');
|
||||
|
||||
$uri = $cell->find('a', 0);
|
||||
if(!$uri)
|
||||
returnServerError('Unable to find uri!');
|
||||
|
||||
return $this->fix_relative_uri($uri->href);
|
||||
}
|
||||
|
||||
private function latest_torrents_extract_author($torrent){
|
||||
$cell = $torrent->find('td.user-row', 0);
|
||||
if(!$cell)
|
||||
return; // No author
|
||||
|
||||
$user = $cell->find('a', 0);
|
||||
if(!$user)
|
||||
returnServerError('Unable to find user!');
|
||||
|
||||
return $user->plaintext;
|
||||
}
|
||||
|
||||
private function latest_torrents_extract_timestamp($torrent){
|
||||
$cell = $torrent->find('td.date-row', 0);
|
||||
if(!$cell)
|
||||
returnServerError('Unable to find date cell!');
|
||||
|
||||
return strtotime('-' . $cell->plaintext, time());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Generic helper functions
|
||||
|
||||
private function load_html($uri){
|
||||
$html = getSimpleHTMLDOM($uri);
|
||||
if(!$html)
|
||||
returnServerError('Unable to load ' . $uri . '!');
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function fix_relative_uri($uri){
|
||||
return preg_replace('/\//i', self::URI, $uri, 1);
|
||||
}
|
||||
|
||||
private function build_category_uri($category, $order_popularity = false){
|
||||
switch($category){
|
||||
case 'anime': $index = 1; break;
|
||||
case 'software' : $index = 2; break;
|
||||
case 'games' : $index = 3; break;
|
||||
case 'adult' : $index = 4; break;
|
||||
case 'movies' : $index = 5; break;
|
||||
case 'music' : $index = 6; break;
|
||||
case 'other' : $index = 7; break;
|
||||
case 'series_tv' : $index = 8; break;
|
||||
case 'books': $index = 9; break;
|
||||
case 'all':
|
||||
default: $index = 0; break;
|
||||
}
|
||||
|
||||
return 'torrents/?iht=' . $index . '&ihs=' . ($order_popularity ? 1 : 0) . '&age=0';
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
@@ -15,7 +15,7 @@ class JapanExpoBridge extends BridgeAbstract {
|
||||
|
||||
public function collectData(){
|
||||
|
||||
function french_pubdate_to_timestamp($date_to_parse) {
|
||||
function frenchPubDateToTimestamp($date_to_parse) {
|
||||
return strtotime(
|
||||
strtr(
|
||||
strtolower(str_replace('Publié le ', '', $date_to_parse)),
|
||||
@@ -53,6 +53,7 @@ class JapanExpoBridge extends BridgeAbstract {
|
||||
$url = $element->href;
|
||||
$thumbnail = 'http://s.japan-expo.com/katana/images/JES049/paris.png';
|
||||
preg_match('/url\(([^)]+)\)/', $element->find('img.rspvimgset', 0)->style, $img_search_result);
|
||||
|
||||
if(count($img_search_result) >= 2)
|
||||
$thumbnail = trim($img_search_result[1], "'");
|
||||
|
||||
@@ -68,13 +69,23 @@ class JapanExpoBridge extends BridgeAbstract {
|
||||
$title = $title_html->plaintext;
|
||||
$headings = $title_html->next_sibling()->outertext;
|
||||
$article = $article_html->find('div.content', 0)->innertext;
|
||||
$article = preg_replace_callback('/<img [^>]+ style="[^\(]+\(\'([^\']+)\'[^>]+>/i', $convert_article_images, $article);
|
||||
$article = preg_replace_callback(
|
||||
'/<img [^>]+ style="[^\(]+\(\'([^\']+)\'[^>]+>/i',
|
||||
$convert_article_images,
|
||||
$article);
|
||||
|
||||
$content = $headings . $article;
|
||||
} else {
|
||||
$date_text = $element->find('span.date', 0)->plaintext;
|
||||
$timestamp = french_pubdate_to_timestamp($date_text);
|
||||
$timestamp = frenchPubDateToTimestamp($date_text);
|
||||
$title = trim($element->find('span._title', 0)->plaintext);
|
||||
$content = '<img src="'.$thumbnail.'"></img><br />'.$date_text.'<br /><a href="'.$url.'">Lire l\'article</a>';
|
||||
$content = '<img src="'
|
||||
. $thumbnail
|
||||
. '"></img><br />'
|
||||
. $date_text
|
||||
. '<br /><a href="'
|
||||
. $url
|
||||
. '">Lire l\'article</a>';
|
||||
}
|
||||
|
||||
$item = array();
|
||||
|
353
bridges/JustETFBridge.php
Normal file
353
bridges/JustETFBridge.php
Normal file
@@ -0,0 +1,353 @@
|
||||
<?php
|
||||
class JustETFBridge extends BridgeAbstract {
|
||||
const NAME = 'justETF Bridge';
|
||||
const URI = 'https://www.justetf.com';
|
||||
const DESCRIPTION = 'Currently only supports the news feed';
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const PARAMETERS = array(
|
||||
'News' => array(
|
||||
'full' => array(
|
||||
'name' => 'Full Article',
|
||||
'type' => 'checkbox',
|
||||
'title' => 'Enable to load full articles'
|
||||
)
|
||||
),
|
||||
'Profile' => array(
|
||||
'isin' => array(
|
||||
'name' => 'ISIN',
|
||||
'type' => 'text',
|
||||
'required' => true,
|
||||
'pattern' => '[a-zA-Z]{2}[a-zA-Z0-9]{10}',
|
||||
'title' => 'ISIN, consisting of 2-letter country code, 9-character identifier, check character'
|
||||
),
|
||||
'strategy' => array(
|
||||
'name' => 'Include Strategy',
|
||||
'type' => 'checkbox',
|
||||
'defaultValue' => 'checked'
|
||||
),
|
||||
'description' => array(
|
||||
'name' => 'Include Description',
|
||||
'type' => 'checkbox',
|
||||
'defaultValue' => 'checked'
|
||||
)
|
||||
),
|
||||
'global' => array(
|
||||
'lang' => array(
|
||||
'name' => 'Language',
|
||||
'required' => true,
|
||||
'type' => 'list',
|
||||
'values' => array(
|
||||
'Englisch' => 'en',
|
||||
'Deutsch' => 'de',
|
||||
'Italiano' => 'it'
|
||||
),
|
||||
'defaultValue' => 'Englisch'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function collectData() {
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Failed loading contents from ' . $this->getURI());
|
||||
|
||||
defaultLinkTo($html, static::URI);
|
||||
|
||||
switch($this->queriedContext) {
|
||||
case 'News':
|
||||
$this->collectNews($html);
|
||||
break;
|
||||
case 'Profile':
|
||||
$this->collectProfile($html);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getURI() {
|
||||
$uri = static::URI;
|
||||
|
||||
if($this->getInput('lang')) {
|
||||
$uri .= '/' . $this->getInput('lang');
|
||||
}
|
||||
|
||||
switch($this->queriedContext) {
|
||||
case 'News':
|
||||
$uri .= '/news';
|
||||
break;
|
||||
case 'Profile':
|
||||
$uri .= '/etf-profile.html?' . http_build_query(array(
|
||||
'isin' => strtoupper($this->getInput('isin'))
|
||||
));
|
||||
break;
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
$name = static::NAME;
|
||||
|
||||
$name .= ($this->queriedContext) ? ' - ' . $this->queriedContext : '';
|
||||
|
||||
switch($this->queriedContext) {
|
||||
case 'News': break;
|
||||
case 'Profile':
|
||||
if($this->getInput('isin')) {
|
||||
$name .= ' ISIN ' . strtoupper($this->getInput('isin'));
|
||||
}
|
||||
}
|
||||
|
||||
if($this->getInput('lang')) {
|
||||
$name .= ' (' . strtoupper($this->getInput('lang')) . ')';
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
#region Common
|
||||
|
||||
/**
|
||||
* Fixes dates depending on the choosen language:
|
||||
*
|
||||
* de : dd.mm.yy
|
||||
* en : dd.mm.yy
|
||||
* it : dd/mm/yy
|
||||
*
|
||||
* Basically strtotime doesn't convert dates correctly due to formats
|
||||
* being hard to interpret. So we use the DateTime object, manually
|
||||
* fixing dates and times (set to 00:00:00.000).
|
||||
*
|
||||
* We don't know the timezone, so just assume +00:00 (or whatever
|
||||
* DateTime chooses)
|
||||
*/
|
||||
private function fixDate($date) {
|
||||
switch($this->getInput('lang')) {
|
||||
case 'en':
|
||||
case 'de':
|
||||
$df = date_create_from_format('d.m.y', $date);
|
||||
break;
|
||||
case 'it':
|
||||
$df = date_create_from_format('d/m/y', $date);
|
||||
break;
|
||||
}
|
||||
|
||||
date_time_set($df, 0, 0);
|
||||
|
||||
// debugMessage(date_format($df, 'U'));
|
||||
|
||||
return date_format($df, 'U');
|
||||
}
|
||||
|
||||
private function extractImages($article) {
|
||||
// Notice: We can have zero or more images (though it should mostly be 1)
|
||||
$elements = $article->find('img');
|
||||
|
||||
$images = array();
|
||||
|
||||
foreach($elements as $img) {
|
||||
// Skip the logo (mostly provided part of a hidden div)
|
||||
if(substr($img->src, strrpos($img->src, '/') + 1) === 'logo.png')
|
||||
continue;
|
||||
|
||||
$images[] = $img->src;
|
||||
}
|
||||
|
||||
return $images;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region News
|
||||
|
||||
private function collectNews($html) {
|
||||
$articles = $html->find('div.newsTopArticle')
|
||||
or returnServerError('No articles found! Layout might have changed!');
|
||||
|
||||
foreach($articles as $article) {
|
||||
|
||||
$item = array();
|
||||
|
||||
// Common data
|
||||
|
||||
$item['uri'] = $this->extractNewsUri($article);
|
||||
$item['timestamp'] = $this->extractNewsDate($article);
|
||||
$item['title'] = $this->extractNewsTitle($article);
|
||||
|
||||
if($this->getInput('full')) {
|
||||
|
||||
$uri = $this->extractNewsUri($article);
|
||||
|
||||
$html = getSimpleHTMLDOMCached($uri)
|
||||
or returnServerError('Failed loading full article from ' . $uri);
|
||||
|
||||
$fullArticle = $html->find('div.article', 0)
|
||||
or returnServerError('No content found! Layout might have changed!');
|
||||
|
||||
defaultLinkTo($fullArticle, static::URI);
|
||||
|
||||
$item['author'] = $this->extractFullArticleAuthor($fullArticle);
|
||||
$item['content'] = $this->extractFullArticleContent($fullArticle);
|
||||
$item['enclosures'] = $this->extractImages($fullArticle);
|
||||
|
||||
} else {
|
||||
|
||||
$item['content'] = $this->extractNewsDescription($article);
|
||||
$item['enclosures'] = $this->extractImages($article);
|
||||
|
||||
}
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function extractNewsUri($article) {
|
||||
$element = $article->find('a', 0)
|
||||
or returnServerError('Anchor not found!');
|
||||
|
||||
return $element->href;
|
||||
}
|
||||
|
||||
private function extractNewsDate($article) {
|
||||
$element = $article->find('div.subheadline', 0)
|
||||
or returnServerError('Date not found!');
|
||||
|
||||
// debugMessage($element->plaintext);
|
||||
|
||||
$date = trim(explode('|', $element->plaintext)[0]);
|
||||
|
||||
return $this->fixDate($date);
|
||||
}
|
||||
|
||||
private function extractNewsDescription($article) {
|
||||
$element = $article->find('span.newsText', 0)
|
||||
or returnServerError('Description not found!');
|
||||
|
||||
$element->find('a', 0)->onclick = '';
|
||||
|
||||
// debugMessage($element->innertext);
|
||||
|
||||
return $element->innertext;
|
||||
}
|
||||
|
||||
private function extractNewsTitle($article) {
|
||||
$element = $article->find('h3', 0)
|
||||
or returnServerError('Title not found!');
|
||||
|
||||
return $element->plaintext;
|
||||
}
|
||||
|
||||
private function extractFullArticleContent($article) {
|
||||
$element = $article->find('div.article_body', 0)
|
||||
or returnServerError('Article body not found!');
|
||||
|
||||
// Remove teaser image
|
||||
$element->find('img.teaser-img', 0)->outertext = '';
|
||||
|
||||
// Remove self advertisements
|
||||
foreach($element->find('.call-action') as $adv) {
|
||||
$adv->outertext = '';
|
||||
}
|
||||
|
||||
// Remove tips
|
||||
foreach($element->find('.panel-edu') as $tip) {
|
||||
$tip->outertext = '';
|
||||
}
|
||||
|
||||
// Remove inline scripts (used for i.e. interactive graphs) as they are
|
||||
// rendered as a long series of strings
|
||||
foreach($element->find('script') as $script) {
|
||||
$script->outertext = '[Content removed! Visit site to see full contents!]';
|
||||
}
|
||||
|
||||
return $element->innertext;
|
||||
}
|
||||
|
||||
private function extractFullArticleAuthor($article) {
|
||||
$element = $article->find('span[itemprop=name]', 0)
|
||||
or returnServerError('Author not found!');
|
||||
|
||||
return $element->plaintext;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Profile
|
||||
|
||||
private function collectProfile($html) {
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = $this->getURI();
|
||||
$item['timestamp'] = $this->extractProfileDate($html);
|
||||
$item['title'] = $this->extractProfiletitle($html);
|
||||
$item['author'] = $this->extractProfileAuthor($html);
|
||||
$item['content'] = $this->extractProfileContent($html);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
private function extractProfileDate($html) {
|
||||
$element = $html->find('div.infobox div.vallabel', 0)
|
||||
or returnServerError('Date not found!');
|
||||
|
||||
// debugMessage($element->plaintext);
|
||||
|
||||
$date = trim(explode("\r\n", $element->plaintext)[1]);
|
||||
|
||||
return $this->fixDate($date);
|
||||
}
|
||||
|
||||
private function extractProfileTitle($html) {
|
||||
$element = $html->find('span.h1', 0)
|
||||
or returnServerError('Title not found!');
|
||||
|
||||
return $element->plaintext;
|
||||
}
|
||||
|
||||
private function extractProfileContent($html) {
|
||||
// There are a few thins we are interested:
|
||||
// - Investment Strategy
|
||||
// - Description
|
||||
// - Quote
|
||||
|
||||
$strategy = $html->find('div.tab-container div.col-sm-6 p', 0)
|
||||
or returnServerError('Investment Strategy not found!');
|
||||
|
||||
// Description requires a bit of cleanup due to lack of propper identification
|
||||
|
||||
$description = $html->find('div.headline', 5)
|
||||
or returnServerError('Description container not found!');
|
||||
|
||||
$description = $description->parent();
|
||||
|
||||
foreach($description->find('div') as $div) {
|
||||
$div->outertext = '';
|
||||
}
|
||||
|
||||
$quote = $html->find('div.infobox div.val', 0)
|
||||
or returnServerError('Quote not found!');
|
||||
|
||||
$quote_html = '<strong>Quote</strong><br><p>' . $quote . '</p>';
|
||||
$strategy_html = '';
|
||||
$description_html = '';
|
||||
|
||||
if($this->getInput('strategy') === true) {
|
||||
$strategy_html = '<strong>Strategy</strong><br><p>' . $strategy . '</p><br>';
|
||||
}
|
||||
|
||||
if($this->getInput('description') === true) {
|
||||
$description_html = '<strong>Description</strong><br><p>' . $description . '</p><br>';
|
||||
}
|
||||
|
||||
return $strategy_html . $description_html . $quote_html;
|
||||
}
|
||||
|
||||
private function extractProfileAuthor($html) {
|
||||
// Use ISIN + WKN as author
|
||||
// Notice: "identfier" is not a typo [sic]!
|
||||
$element = $html->find('span.identfier', 0)
|
||||
or returnServerError('Author not found!');
|
||||
|
||||
return $element->plaintext;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
123
bridges/KATBridge.php
Normal file
123
bridges/KATBridge.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
class KATBridge extends BridgeAbstract {
|
||||
const MAINTAINER = 'niawag';
|
||||
const NAME = 'KickassTorrents';
|
||||
const URI = 'https://katcr.co/new/';
|
||||
const DESCRIPTION = 'Returns results for the keywords. You can put several
|
||||
list of keywords by separating them with a semicolon (e.g. "one show;another
|
||||
show"). Category based search needs the category number as input. User based
|
||||
search takes the Uploader ID: see KAT URL for user feed. Search can be done in a specified category';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'q' => array(
|
||||
'name' => 'keywords, separated by semicolons',
|
||||
'exampleValue' => 'first list;second list;…',
|
||||
'required' => true
|
||||
),
|
||||
'crit' => array(
|
||||
'type' => 'list',
|
||||
'name' => 'Search type',
|
||||
'values' => array(
|
||||
'search' => 'search',
|
||||
'category' => 'cat',
|
||||
'user' => 'usr'
|
||||
)
|
||||
),
|
||||
'cat_check' => array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'Specify category for normal search ?',
|
||||
),
|
||||
'cat' => array(
|
||||
'name' => 'Category number',
|
||||
'exampleValue' => '100, 200… See KAT for category number'
|
||||
),
|
||||
'trusted' => array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'Only get results from Elite or Verified uploaders ?',
|
||||
),
|
||||
));
|
||||
public function collectData(){
|
||||
function parseDateTimestamp($element){
|
||||
$guessedDate = strptime($element, '%d-%m-%Y %H:%M:%S');
|
||||
$timestamp = mktime(
|
||||
$guessedDate['tm_hour'],
|
||||
$guessedDate['tm_min'],
|
||||
$guessedDate['tm_sec'],
|
||||
$guessedDate['tm_mon'] + 1,
|
||||
$guessedDate['tm_mday'],
|
||||
$guessedDate['tm_year'] + 1900);
|
||||
return $timestamp;
|
||||
}
|
||||
$catBool = $this->getInput('cat_check');
|
||||
if($catBool) {
|
||||
$catNum = $this->getInput('cat');
|
||||
}
|
||||
$critList = $this->getInput('crit');
|
||||
$trustedBool = $this->getInput('trusted');
|
||||
$keywordsList = explode(';', $this->getInput('q'));
|
||||
foreach($keywordsList as $keywords) {
|
||||
switch($critList) {
|
||||
case 'search':
|
||||
if($catBool == false) {
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI .
|
||||
'torrents-search.php?search=' .
|
||||
rawurlencode($keywords)
|
||||
) or returnServerError('Could not request KAT.');
|
||||
} else {
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI .
|
||||
'torrents-search.php?search=' .
|
||||
rawurlencode($keywords) .
|
||||
'&cat=' .
|
||||
rawurlencode($catNum)
|
||||
) or returnServerError('Could not request KAT.');
|
||||
}
|
||||
break;
|
||||
case 'cat':
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI .
|
||||
'torrents.php?cat=' .
|
||||
rawurlencode($keywords)
|
||||
) or returnServerError('Could not request KAT.');
|
||||
break;
|
||||
case 'usr':
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI .
|
||||
'account-details.php?id=' .
|
||||
rawurlencode($keywords)
|
||||
) or returnServerError('Could not request KAT.');
|
||||
break;
|
||||
}
|
||||
if ($html->find('table.ttable_headinner', 0) == false)
|
||||
returnServerError('No result for query ' . $keywords);
|
||||
foreach($html->find('tr.t-row') as $element) {
|
||||
if(!$trustedBool
|
||||
|| !is_null($element->find('i[title="Elite Uploader"]', 0))
|
||||
|| !is_null($element->find('i[title="Verified Uploader"]', 0))) {
|
||||
$item = array();
|
||||
$item['uri'] = self::URI . $element->find('a', 2)->href;
|
||||
$item['id'] = self::URI . $element->find('a.cellMainLink', 0)->href;
|
||||
$item['timestamp'] = parseDateTimestamp($element->find('td', 2)->plaintext);
|
||||
$item['author'] = $element->find('a.plain', 0)->plaintext;
|
||||
$item['title'] = $element->find('a.cellMainLink', 0)->plaintext;
|
||||
$item['seeders'] = (int)$element->find('td', 3)->plaintext;
|
||||
$item['leechers'] = (int)$element->find('td', 4)->plaintext;
|
||||
$item['size'] = $element->find('td', 1)->plaintext;
|
||||
$item['content'] = $item['title']
|
||||
. '<br>size: '
|
||||
. $item['size']
|
||||
. '<br>seeders: '
|
||||
. $item['seeders']
|
||||
. ' | leechers: '
|
||||
. $item['leechers']
|
||||
. '<br><a href="'
|
||||
. $item['id']
|
||||
. '">info page</a>';
|
||||
if(isset($item['title']))
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
150
bridges/KernelBugTrackerBridge.php
Normal file
150
bridges/KernelBugTrackerBridge.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
class KernelBugTrackerBridge extends BridgeAbstract {
|
||||
|
||||
const NAME = 'Kernel Bug Tracker';
|
||||
const URI = 'https://bugzilla.kernel.org';
|
||||
const DESCRIPTION = 'Returns feeds for bug comments';
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const PARAMETERS = array(
|
||||
'Bug comments' => array(
|
||||
'id' => array(
|
||||
'name' => 'Bug tracking ID',
|
||||
'type' => 'number',
|
||||
'required' => true,
|
||||
'title' => 'Insert bug tracking ID',
|
||||
'exampleValue' => 121241
|
||||
),
|
||||
'limit' => array(
|
||||
'name' => 'Number of comments to return',
|
||||
'type' => 'number',
|
||||
'required' => false,
|
||||
'title' => 'Specify number of comments to return',
|
||||
'defaultValue' => -1
|
||||
),
|
||||
'sorting' => array(
|
||||
'name' => 'Sorting',
|
||||
'type' => 'list',
|
||||
'required' => false,
|
||||
'title' => 'Defines the sorting order of the comments returned',
|
||||
'defaultValue' => 'of',
|
||||
'values' => array(
|
||||
'Oldest first' => 'of',
|
||||
'Latest first' => 'lf'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
private $bugid = '';
|
||||
private $bugdesc = '';
|
||||
|
||||
public function collectData(){
|
||||
$limit = $this->getInput('limit');
|
||||
$sorting = $this->getInput('sorting');
|
||||
|
||||
// We use the print preview page for simplicity
|
||||
$html = getSimpleHTMLDOMCached($this->getURI() . '&format=multiple',
|
||||
86400,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
true,
|
||||
DEFAULT_TARGET_CHARSET,
|
||||
false, // Do NOT remove line breaks
|
||||
DEFAULT_BR_TEXT,
|
||||
DEFAULT_SPAN_TEXT);
|
||||
|
||||
if($html === false)
|
||||
returnServerError('Failed to load page!');
|
||||
|
||||
// Store header information into private members
|
||||
$this->bugid = $html->find('#bugzilla-body', 0)->find('a', 0)->innertext;
|
||||
$this->bugdesc = $html->find('table.bugfields', 0)->find('tr', 0)->find('td', 0)->innertext;
|
||||
|
||||
// Get and limit comments
|
||||
$comments = $html->find('div.bz_comment');
|
||||
|
||||
if($limit > 0 && count($comments) > $limit) {
|
||||
$comments = array_slice($comments, count($comments) - $limit, $limit);
|
||||
}
|
||||
|
||||
// Order comments
|
||||
switch($sorting) {
|
||||
case 'lf': $comments = array_reverse($comments, true);
|
||||
case 'of':
|
||||
default: // Nothing to do, keep original order
|
||||
}
|
||||
|
||||
foreach($comments as $comment) {
|
||||
$comment = $this->inlineStyles($comment);
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = $this->getURI() . '#' . $comment->id;
|
||||
$item['author'] = $comment->find('span.bz_comment_user', 0)->innertext;
|
||||
$item['title'] = $comment->find('span.bz_comment_number', 0)->find('a', 0)->innertext;
|
||||
$item['timestamp'] = strtotime($comment->find('span.bz_comment_time', 0)->innertext);
|
||||
$item['content'] = $comment->find('pre.bz_comment_text', 0)->innertext;
|
||||
|
||||
// Fix line breaks (they use LF)
|
||||
$item['content'] = str_replace("\n", '<br>', $item['content']);
|
||||
|
||||
// Fix relative URIs
|
||||
$item['content'] = $this->replaceRelativeURI($item['content']);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
switch($this->queriedContext) {
|
||||
case 'Bug comments':
|
||||
return parent::getURI()
|
||||
. '/show_bug.cgi?id='
|
||||
. $this->getInput('id');
|
||||
break;
|
||||
default: return parent::getURI();
|
||||
}
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
switch($this->queriedContext) {
|
||||
case 'Bug comments':
|
||||
return 'Bug '
|
||||
. $this->bugid
|
||||
. ' tracker for '
|
||||
. $this->bugdesc
|
||||
. ' - '
|
||||
. parent::getName();
|
||||
break;
|
||||
default: return parent::getName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all relative URIs with absolute ones
|
||||
*
|
||||
* @param string $content The source string
|
||||
* @return string Returns the source string with all relative URIs replaced
|
||||
* by absolute ones.
|
||||
*/
|
||||
private function replaceRelativeURI($content){
|
||||
return preg_replace('/href="(?!http)/', 'href="' . self::URI . '/', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds styles as attributes to tags with known classes
|
||||
*
|
||||
* @param object $html A simplehtmldom object
|
||||
* @return object Returns the original object with styles added as
|
||||
* attributes.
|
||||
*/
|
||||
private function inlineStyles($html){
|
||||
foreach($html->find('.bz_obsolete') as $element) {
|
||||
$element->style = 'text-decoration:line-through;';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
@@ -3,9 +3,9 @@ require_once('MoebooruBridge.php');
|
||||
|
||||
class KonachanBridge extends MoebooruBridge {
|
||||
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Konachan";
|
||||
const URI = "http://konachan.com/";
|
||||
const DESCRIPTION = "Returns images from given page";
|
||||
const MAINTAINER = 'mitsukarenai';
|
||||
const NAME = 'Konachan';
|
||||
const URI = 'http://konachan.com/';
|
||||
const DESCRIPTION = 'Returns images from given page';
|
||||
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
class KoreusBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = "pit-fgfjiudghdf";
|
||||
const NAME = "Koreus";
|
||||
const URI = "http://www.koreus.com/";
|
||||
const DESCRIPTION = "Returns the newest posts from Koreus (full text)";
|
||||
const MAINTAINER = 'pit-fgfjiudghdf';
|
||||
const NAME = 'Koreus';
|
||||
const URI = 'http://www.koreus.com/';
|
||||
const DESCRIPTION = 'Returns the newest posts from Koreus (full text)';
|
||||
|
||||
protected function parseItem($item){
|
||||
$item = parent::parseItem($item);
|
||||
|
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
class KununuBridge extends BridgeAbstract {
|
||||
const MAINTAINER = "logmanoriginal";
|
||||
const NAME = "Kununu Bridge";
|
||||
const URI = "https://www.kununu.com/";
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const NAME = 'Kununu Bridge';
|
||||
const URI = 'https://www.kununu.com/';
|
||||
const CACHE_TIMEOUT = 86400; // 24h
|
||||
const DESCRIPTION = "Returns the latest reviews for a company and site of your choice.";
|
||||
const DESCRIPTION = 'Returns the latest reviews for a company and site of your choice.';
|
||||
|
||||
const PARAMETERS = array(
|
||||
'global' => array(
|
||||
@@ -28,7 +28,6 @@ class KununuBridge extends BridgeAbstract {
|
||||
'title' => 'Activate to load full article'
|
||||
)
|
||||
),
|
||||
|
||||
array(
|
||||
'company' => array(
|
||||
'name' => 'Company',
|
||||
@@ -42,9 +41,12 @@ class KununuBridge extends BridgeAbstract {
|
||||
private $companyName = '';
|
||||
|
||||
public function getURI(){
|
||||
$company = $this->encode_umlauts(strtolower(str_replace(' ', '-', trim($this->getInput('company')))));
|
||||
if(!is_null($this->getInput('company')) && !is_null($this->getInput('site'))) {
|
||||
|
||||
$company = $this->fixCompanyName($this->getInput('company'));
|
||||
$site = $this->getInput('site');
|
||||
$section = '';
|
||||
|
||||
switch($site) {
|
||||
case 'at':
|
||||
case 'de':
|
||||
@@ -56,23 +58,30 @@ class KununuBridge extends BridgeAbstract {
|
||||
break;
|
||||
}
|
||||
|
||||
return self::URI.$site.'/'.$company.'/'.$section;
|
||||
return self::URI . $site . '/' . $company . '/' . $section . '?sort=update_time_desc';
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
|
||||
function getName(){
|
||||
$company = $this->encode_umlauts(strtolower(str_replace(' ', '-', trim($this->getInput('company')))));
|
||||
if(!is_null($this->getInput('company'))) {
|
||||
$company = $this->fixCompanyName($this->getInput('company'));
|
||||
return ($this->companyName ?: $company) . ' - ' . self::NAME;
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
$full = $this->getInput('full');
|
||||
|
||||
// Load page
|
||||
$html = getSimpleHTMLDOM($this->getURI());
|
||||
$html = getSimpleHTMLDOMCached($this->getURI());
|
||||
if(!$html)
|
||||
returnServerError('Unable to receive data from ' . $this->getURI() . '!');
|
||||
// Update name for this request
|
||||
$this->companyName = $this->extract_company_name($html);
|
||||
$this->companyName = $this->extractCompanyName($html);
|
||||
|
||||
// Find the section with all the panels (reviews)
|
||||
$section = $html->find('section.kununu-scroll-element', 0);
|
||||
@@ -88,15 +97,18 @@ class KununuBridge extends BridgeAbstract {
|
||||
foreach($articles as $article) {
|
||||
$item = array();
|
||||
|
||||
$item['author'] = $this->extract_article_author_position($article);
|
||||
$item['timestamp'] = $this->extract_article_date($article);
|
||||
$item['title'] = $this->extract_article_rating($article) . ' : ' . $this->extract_article_summary($article);
|
||||
$item['uri'] = $this->extract_article_uri($article);
|
||||
$item['author'] = $this->extractArticleAuthorPosition($article);
|
||||
$item['timestamp'] = $this->extractArticleDate($article);
|
||||
$item['title'] = $this->extractArticleRating($article)
|
||||
. ' : '
|
||||
. $this->extractArticleSummary($article);
|
||||
|
||||
$item['uri'] = $this->extractArticleUri($article);
|
||||
|
||||
if($full)
|
||||
$item['content'] = $this->extract_full_description($item['uri']);
|
||||
$item['content'] = $this->extractFullDescription($item['uri']);
|
||||
else
|
||||
$item['content'] = $this->extract_article_description($article);
|
||||
$item['content'] = $this->extractArticleDescription($article);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
@@ -105,16 +117,26 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Fixes relative URLs in the given text
|
||||
*/
|
||||
private function fix_url($text){
|
||||
private function fixUrl($text){
|
||||
return preg_replace('/href=(\'|\")\//i', 'href="'.self::URI, $text);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a fixed version of the provided company name
|
||||
*/
|
||||
private function fixCompanyName($company){
|
||||
$company = trim($company);
|
||||
$company = str_replace(' ', '-', $company);
|
||||
$company = strtolower($company);
|
||||
return $this->encodeUmlauts($company);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes unmlauts in the given text
|
||||
*/
|
||||
private function encode_umlauts($text){
|
||||
$umlauts = Array("/ä/","/ö/","/ü/","/Ä/","/Ö/","/Ü/","/ß/");
|
||||
$replace = Array("ae","oe","ue","Ae","Oe","Ue","ss");
|
||||
private function encodeUmlauts($text){
|
||||
$umlauts = Array('/ä/','/ö/','/ü/','/Ä/','/Ö/','/Ü/','/ß/');
|
||||
$replace = Array('ae','oe','ue','Ae','Oe','Ue','ss');
|
||||
|
||||
return preg_replace($umlauts, $replace, $text);
|
||||
}
|
||||
@@ -122,13 +144,9 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the company name from the review html
|
||||
*/
|
||||
private function extract_company_name($html){
|
||||
$panel = $html->find('div.panel', 0);
|
||||
if($panel === false)
|
||||
returnServerError('Cannot find panel for company name!');
|
||||
|
||||
$company_name = $panel->find('h1', 0);
|
||||
if($company_name === false)
|
||||
private function extractCompanyName($html){
|
||||
$company_name = $html->find('h1[itemprop=name]', 0);
|
||||
if(is_null($company_name))
|
||||
returnServerError('Cannot find company name!');
|
||||
|
||||
return $company_name->plaintext;
|
||||
@@ -137,21 +155,21 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the date from a given article
|
||||
*/
|
||||
private function extract_article_date($article){
|
||||
private function extractArticleDate($article){
|
||||
// They conviniently provide a time attribute for us :)
|
||||
$date = $article->find('time[itemprop=dtreviewed]', 0);
|
||||
if($date === false)
|
||||
$date = $article->find('meta[itemprop=dateCreated]', 0);
|
||||
if(is_null($date))
|
||||
returnServerError('Cannot find article date!');
|
||||
|
||||
return strtotime($date->datetime);
|
||||
return strtotime($date->content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rating from a given article
|
||||
*/
|
||||
private function extract_article_rating($article){
|
||||
private function extractArticleRating($article){
|
||||
$rating = $article->find('span.rating', 0);
|
||||
if($rating === false)
|
||||
if(is_null($rating))
|
||||
returnServerError('Cannot find article rating!');
|
||||
|
||||
return $rating->getAttribute('aria-label');
|
||||
@@ -160,9 +178,9 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the summary from a given article
|
||||
*/
|
||||
private function extract_article_summary($article){
|
||||
$summary = $article->find('[itemprop=summary]', 0);
|
||||
if($summary === false)
|
||||
private function extractArticleSummary($article){
|
||||
$summary = $article->find('[itemprop=name]', 0);
|
||||
if(is_null($summary))
|
||||
returnServerError('Cannot find article summary!');
|
||||
|
||||
return strip_tags($summary->innertext);
|
||||
@@ -171,14 +189,9 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the URI from a given article
|
||||
*/
|
||||
private function extract_article_uri($article){
|
||||
// Notice: This first part is the same as in extract_article_summary!
|
||||
$summary = $article->find('[itemprop=summary]', 0);
|
||||
if($summary === false)
|
||||
returnServerError('Cannot find article summary!');
|
||||
|
||||
$anchor = $summary->find('a', 0);
|
||||
if($anchor === false)
|
||||
private function extractArticleUri($article){
|
||||
$anchor = $article->find('h1.review-title a', 0);
|
||||
if(is_null($anchor))
|
||||
returnServerError('Cannot find article URI!');
|
||||
|
||||
return self::URI . $anchor->href;
|
||||
@@ -187,17 +200,17 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the position of the author from a given article
|
||||
*/
|
||||
private function extract_article_author_position($article){
|
||||
// We need to parse the aside manually
|
||||
$aside = $article->find('aside', 0);
|
||||
if($aside === false)
|
||||
returnServerError('Cannot find article author information!');
|
||||
private function extractArticleAuthorPosition($article){
|
||||
// We need to parse the user-content manually
|
||||
$user_content = $article->find('div.user-content', 0);
|
||||
if(is_null($user_content))
|
||||
returnServerError('Cannot find user content!');
|
||||
|
||||
// Go through all h2 elements to find index of required span (I know... it's stupid)
|
||||
$author_position = 'Unknown';
|
||||
foreach($aside->find('h2') as $subject){
|
||||
if(stristr(strtolower($subject->plaintext), 'position')){ /* This works for at, ch, de, us */
|
||||
$author_position = $subject->next_sibling()->plaintext;
|
||||
foreach($user_content->find('div') as $content) {
|
||||
if(stristr(strtolower($content->plaintext), 'position')) { /* This works for at, ch, de, us */
|
||||
$author_position = $content->next_sibling()->plaintext;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -208,18 +221,18 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the description from a given article
|
||||
*/
|
||||
private function extract_article_description($article){
|
||||
$description = $article->find('div[itemprop=description]', 0);
|
||||
if($description === false)
|
||||
private function extractArticleDescription($article){
|
||||
$description = $article->find('[itemprop=reviewBody]', 0);
|
||||
if(is_null($description))
|
||||
returnServerError('Cannot find article description!');
|
||||
|
||||
return $this->fix_url($description->innertext);
|
||||
return $this->fixUrl($description->innertext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full description from a given uri
|
||||
*/
|
||||
private function extract_full_description($uri){
|
||||
private function extractFullDescription($uri){
|
||||
// Load full article
|
||||
$html = getSimpleHTMLDOMCached($uri);
|
||||
if($html === false)
|
||||
@@ -227,10 +240,10 @@ class KununuBridge extends BridgeAbstract {
|
||||
|
||||
// Find the article
|
||||
$article = $html->find('article', 0);
|
||||
if($article === false)
|
||||
if(is_null($article))
|
||||
returnServerError('Cannot find article!');
|
||||
|
||||
// Luckily they use the same layout for the review overview and full article pages :)
|
||||
return $this->extract_article_description($article);
|
||||
return $this->extractArticleDescription($article);
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,8 @@ class LWNprevBridge extends BridgeAbstract{
|
||||
const CACHE_TIMEOUT = 604800; // 1 week
|
||||
const DESCRIPTION = 'LWN Free Weekly Edition available one week late';
|
||||
|
||||
private $editionTimeStamp;
|
||||
|
||||
function getURI(){
|
||||
return self::URI.'free/bigpage';
|
||||
}
|
||||
@@ -36,99 +38,64 @@ class LWNprevBridge extends BridgeAbstract{
|
||||
$content = getContents($this->getURI())
|
||||
or returnServerError('No results for LWNprev');
|
||||
|
||||
$contents = explode('<b>Page editor</b>', $content);
|
||||
|
||||
foreach($contents as $content) {
|
||||
if(strpos($content, '<html>') === false) {
|
||||
$content = <<<EOD
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html><head><title>LWN</title></head><body>{$content}</body></html>
|
||||
EOD;
|
||||
} else {
|
||||
$content = $content.'</body></html>';
|
||||
}
|
||||
|
||||
libxml_use_internal_errors(true);
|
||||
$html = new DOMDocument();
|
||||
$html->loadHTML($content);
|
||||
libxml_clear_errors();
|
||||
|
||||
$cat1='';
|
||||
$cat2='';
|
||||
|
||||
foreach($html->getElementsByTagName('a') as $a){
|
||||
if($a->textContent==='Multi-page format'){
|
||||
break;
|
||||
}
|
||||
}
|
||||
$realURI=self::URI.$a->getAttribute('href');
|
||||
$URICounter=0;
|
||||
|
||||
$edition=$html->getElementsByTagName('h1')->item(0)->textContent;
|
||||
$editionTimeStamp=strtotime(
|
||||
substr($edition,strpos($edition,'for ')+strlen('for '))
|
||||
$edition = $html->getElementsByTagName('h1');
|
||||
if($edition->length !== 0) {
|
||||
$text = $edition->item(0)->textContent;
|
||||
$this->editionTimeStamp = strtotime(
|
||||
substr($text, strpos($text, 'for ') + strlen('for '))
|
||||
);
|
||||
|
||||
foreach($html->getElementsByTagName('h2') as $h2){
|
||||
if($h2->getAttribute('class')!=='SummaryHL'){
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = array();
|
||||
|
||||
$h2NextSibling=$h2->nextSibling;
|
||||
$this->jumpToNextTag($h2NextSibling);
|
||||
|
||||
switch($h2NextSibling->getAttribute('class')){
|
||||
case 'FeatureByline':
|
||||
$item['author']=$h2NextSibling->getElementsByTagName('b')->item(0)->textContent;
|
||||
break;
|
||||
case 'GAByline':
|
||||
$text=$h2NextSibling->textContent;
|
||||
$item['author']=substr($text,strpos($text,'by '));
|
||||
break;
|
||||
default:
|
||||
$item['author']='LWN';
|
||||
break;
|
||||
};
|
||||
|
||||
$h2FirstChild=$h2->firstChild;
|
||||
$this->jumpToNextTag($h2FirstChild);
|
||||
if($h2FirstChild->nodeName==='a'){
|
||||
$item['uri']=self::URI.$h2FirstChild->getAttribute('href');
|
||||
if(strpos($content, 'Cat1HL') === false) {
|
||||
$items = $this->getFeatureContents($html);
|
||||
} elseif(strpos($content, 'Cat3HL') === false) {
|
||||
$items = $this->getBriefItems($html);
|
||||
} else {
|
||||
$item['uri']=$realURI.'#'.$URICounter;
|
||||
$items = $this->getAnnouncements($html);
|
||||
}
|
||||
$URICounter++;
|
||||
|
||||
$item['timestamp']=$editionTimeStamp+$URICounter;
|
||||
|
||||
$h2PrevSibling=$h2->previousSibling;
|
||||
$this->jumpToPreviousTag($h2PrevSibling);
|
||||
switch($h2PrevSibling->getAttribute('class')){
|
||||
case 'Cat2HL':
|
||||
$cat2=$h2PrevSibling->textContent;
|
||||
$h2PrevSibling=$h2PrevSibling->previousSibling;
|
||||
$this->jumpToPreviousTag($h2PrevSibling);
|
||||
if($h2PrevSibling->getAttribute('class')!=='Cat1HL'){
|
||||
break;
|
||||
$this->items = array_merge($this->items, $items);
|
||||
}
|
||||
$cat1=$h2PrevSibling->textContent;
|
||||
break;
|
||||
case 'Cat1HL':
|
||||
$cat1=$h2PrevSibling->textContent;
|
||||
$cat2='';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$h2PrevSibling=null;
|
||||
|
||||
$item['title']='';
|
||||
if(!empty($cat1)){
|
||||
$item['title'].='['.$cat1.($cat2?'/'.$cat2:'').'] ';
|
||||
private function getArticleContent(&$title){
|
||||
$link = $title->firstChild;
|
||||
$this->jumpToNextTag($link);
|
||||
$item['uri'] = self::URI;
|
||||
if($link->nodeName === 'a') {
|
||||
$item['uri'] .= $link->getAttribute('href');
|
||||
}
|
||||
$item['title'].=$h2->textContent;
|
||||
|
||||
$node=$h2;
|
||||
$item['timestamp'] = $this->editionTimeStamp;
|
||||
|
||||
$node = $title;
|
||||
$content = '';
|
||||
$contentEnd = false;
|
||||
while(!$contentEnd) {
|
||||
$node = $node->nextSibling;
|
||||
if(
|
||||
!$node || (
|
||||
$node->nodeType!==XML_TEXT_NODE && (
|
||||
$node->nodeName==='h2' ||
|
||||
(!is_null($node->attributes) && !is_null($class=$node->attributes->getNamedItem('class')) &&
|
||||
in_array($class->nodeValue,array('Cat1HL','Cat2HL')))
|
||||
if(!$node || (
|
||||
$node->nodeType !== XML_TEXT_NODE &&
|
||||
$node->nodeName === 'h2' || (
|
||||
!is_null($node->attributes) &&
|
||||
!is_null($class = $node->attributes->getNamedItem('class')) &&
|
||||
in_array($class->nodeValue, array('Cat1HL','Cat2HL'))
|
||||
)
|
||||
)
|
||||
) {
|
||||
@@ -138,7 +105,161 @@ class LWNprevBridge extends BridgeAbstract{
|
||||
}
|
||||
}
|
||||
$item['content'] = $content;
|
||||
$this->items[]=$item;
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function getFeatureContents(&$html){
|
||||
$items = array();
|
||||
foreach($html->getElementsByTagName('h2') as $title) {
|
||||
if($title->getAttribute('class') !== 'SummaryHL') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = array();
|
||||
|
||||
$author = $title->nextSibling;
|
||||
$this->jumpToNextTag($author);
|
||||
if($author->getAttribute('class') === 'FeatureByline') {
|
||||
$item['author'] = $author->getElementsByTagName('b')->item(0)->textContent;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item['title'] = $title->textContent;
|
||||
|
||||
$items[] = array_merge($item, $this->getArticleContent($title));
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getItemPrefix(&$cat, &$cats){
|
||||
$cat1 = '';
|
||||
$cat2 = '';
|
||||
$cat3 = '';
|
||||
switch($cat->getAttribute('class')) {
|
||||
case 'Cat3HL':
|
||||
$cat3 = $cat->textContent;
|
||||
$cat = $cat->previousSibling;
|
||||
$this->jumpToPreviousTag($cat);
|
||||
$cats[2] = $cat3;
|
||||
if($cat->getAttribute('class') !== 'Cat2HL') {
|
||||
break;
|
||||
}
|
||||
case 'Cat2HL':
|
||||
$cat2 = $cat->textContent;
|
||||
$cat = $cat->previousSibling;
|
||||
$this->jumpToPreviousTag($cat);
|
||||
$cats[1] = $cat2;
|
||||
if(empty($cat3)) {
|
||||
$cats[2] = '';
|
||||
}
|
||||
if($cat->getAttribute('class') !== 'Cat1HL') {
|
||||
break;
|
||||
}
|
||||
case 'Cat1HL':
|
||||
$cat1 = $cat->textContent;
|
||||
$cats[0] = $cat1;
|
||||
if(empty($cat3)) {
|
||||
$cats[2] = '';
|
||||
}
|
||||
if(empty($cat2)) {
|
||||
$cats[1] = '';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$prefix = '';
|
||||
if(!empty($cats[0])) {
|
||||
$prefix .= '['.$cats[0].($cats[1] ? '/'.$cats[1] : '').'] ';
|
||||
}
|
||||
return $prefix;
|
||||
}
|
||||
|
||||
private function getAnnouncements(&$html){
|
||||
$items = array();
|
||||
$cats = array('','','');
|
||||
|
||||
foreach($html->getElementsByTagName('p') as $newsletters) {
|
||||
if($newsletters->getAttribute('class') !== 'Cat3HL') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = array();
|
||||
|
||||
$item['uri'] = self::URI.'#'.count($items);
|
||||
|
||||
$item['timestamp'] = $this->editionTimeStamp;
|
||||
|
||||
$item['author'] = 'LWN';
|
||||
|
||||
$cat = $newsletters->previousSibling;
|
||||
$this->jumpToPreviousTag($cat);
|
||||
$prefix = $this->getItemPrefix($cat, $cats);
|
||||
$item['title'] = $prefix.' '.$newsletters->textContent;
|
||||
|
||||
$node = $newsletters;
|
||||
$content = '';
|
||||
$contentEnd = false;
|
||||
while(!$contentEnd) {
|
||||
$node = $node->nextSibling;
|
||||
if(!$node || (
|
||||
$node->nodeType !== XML_TEXT_NODE && (
|
||||
!is_null($node->attributes) &&
|
||||
!is_null($class = $node->attributes->getNamedItem('class')) &&
|
||||
in_array($class->nodeValue, array('Cat1HL','Cat2HL','Cat3HL'))
|
||||
)
|
||||
)
|
||||
) {
|
||||
$contentEnd = true;
|
||||
} else {
|
||||
$content .= $node->C14N();
|
||||
}
|
||||
}
|
||||
$item['content'] = $content;
|
||||
$items[] = $item;
|
||||
}
|
||||
|
||||
foreach($html->getElementsByTagName('h2') as $title) {
|
||||
if($title->getAttribute('class') !== 'SummaryHL') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = array();
|
||||
|
||||
$cat = $title->previousSibling;
|
||||
$this->jumpToPreviousTag($cat);
|
||||
$cat = $cat->previousSibling;
|
||||
$this->jumpToPreviousTag($cat);
|
||||
$prefix = $this->getItemPrefix($cat, $cats);
|
||||
$item['title'] = $prefix.' '.$title->textContent;
|
||||
$items[] = array_merge($item, $this->getArticleContent($title));
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
private function getBriefItems(&$html){
|
||||
$items = array();
|
||||
$cats = array('','','');
|
||||
foreach($html->getElementsByTagName('h2') as $title) {
|
||||
if($title->getAttribute('class') !== 'SummaryHL') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$item = array();
|
||||
|
||||
$cat = $title->previousSibling;
|
||||
$this->jumpToPreviousTag($cat);
|
||||
$cat = $cat->previousSibling;
|
||||
$this->jumpToPreviousTag($cat);
|
||||
$prefix = $this->getItemPrefix($cat, $cats);
|
||||
$item['title'] = $prefix.' '.$title->textContent;
|
||||
$items[] = array_merge($item, $this->getArticleContent($title));
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
300
bridges/LeBonCoinBridge.php
Executable file → Normal file
300
bridges/LeBonCoinBridge.php
Executable file → Normal file
@@ -1,136 +1,150 @@
|
||||
<?php
|
||||
class LeBonCoinBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "16mhz";
|
||||
const NAME = "LeBonCoin";
|
||||
const URI = "http://www.leboncoin.fr/";
|
||||
const DESCRIPTION = "Returns most recent results from LeBonCoin for a region, and optionally a category and a keyword .";
|
||||
const MAINTAINER = 'jacknumber';
|
||||
const NAME = 'LeBonCoin';
|
||||
const URI = 'https://www.leboncoin.fr/';
|
||||
const DESCRIPTION = 'Returns most recent results from LeBonCoin';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
const PARAMETERS = array(
|
||||
array(
|
||||
'k' => array('name' => 'Mot Clé'),
|
||||
'r' => array(
|
||||
'name' => 'Région',
|
||||
'type' => 'list',
|
||||
'values' => array(
|
||||
'Toute la France'=>'ile_de_france/occasions',
|
||||
'Alsace'=>'alsace',
|
||||
'Aquitaine'=>'aquitaine',
|
||||
'Auvergne'=>'auvergne',
|
||||
'Basse Normandie'=>'basse_normandie',
|
||||
'Bourgogne'=>'bourgogne',
|
||||
'Bretagne'=>'bretagne',
|
||||
'Centre'=>'centre',
|
||||
'Champagne Ardenne'=>'champagne_ardenne',
|
||||
'Corse'=>'corse',
|
||||
'Franche Comté'=>'franche_comte',
|
||||
'Haute Normandie'=>'haute_normandie',
|
||||
'Ile de France'=>'ile_de_france',
|
||||
'Languedoc Roussillon'=>'languedoc_roussillon',
|
||||
'Limousin'=>'limousin',
|
||||
'Lorraine'=>'lorraine',
|
||||
'Midi Pyrénées'=>'midi_pyrenees',
|
||||
'Nord Pas De Calais'=>'nord_pas_de_calais',
|
||||
'Pays de la Loire'=>'pays_de_la_loire',
|
||||
'Picardie'=>'picardie',
|
||||
'Poitou Charentes'=>'poitou_charentes',
|
||||
'Provence Alpes Côte d\'Azur'=>'provence_alpes_cote_d_azur',
|
||||
'Rhône-Alpes'=>'rhone_alpes',
|
||||
'Guadeloupe'=>'guadeloupe',
|
||||
'Martinique'=>'martinique',
|
||||
'Guyane'=>'guyane',
|
||||
'Réunion'=>'reunion'
|
||||
'Toute la France' => '',
|
||||
'Alsace' => '1',
|
||||
'Aquitaine' => '2',
|
||||
'Auvergne' => '3',
|
||||
'Basse Normandie' => '4',
|
||||
'Bourgogne' => '5',
|
||||
'Bretagne' => '6',
|
||||
'Centre' => '7',
|
||||
'Champagne Ardenne' => '8',
|
||||
'Corse' => '9',
|
||||
'Franche Comté' => '10',
|
||||
'Haute Normandie' => '11',
|
||||
'Ile de France' => '12',
|
||||
'Languedoc Roussillon' => '13',
|
||||
'Limousin' => '14',
|
||||
'Lorraine' => '15',
|
||||
'Midi Pyrénées' => '16',
|
||||
'Nord Pas De Calais' => '17',
|
||||
'Pays de la Loire' => '18',
|
||||
'Picardie' => '19',
|
||||
'Poitou Charentes' => '20',
|
||||
'Provence Alpes Côte d\'Azur' => '21',
|
||||
'Rhône-Alpes' => '22',
|
||||
'Guadeloupe' => '23',
|
||||
'Martinique' => '24',
|
||||
'Guyane' => '25',
|
||||
'Réunion' => '26'
|
||||
)
|
||||
),
|
||||
'cities' => array('name' => 'Ville'),
|
||||
'c' => array(
|
||||
'name' => 'Catégorie',
|
||||
'type' => 'list',
|
||||
'values' => array(
|
||||
'TOUS'=>'',
|
||||
'EMPLOI'=>'_emploi_',
|
||||
'Toutes catégories' => '',
|
||||
'EMPLOI' => array(
|
||||
'Emploi et recrutement' => '71',
|
||||
'Offres d\'emploi et jobs' => '33'
|
||||
),
|
||||
'VEHICULES' => array(
|
||||
'Tous'=>'_vehicules_',
|
||||
'Voitures'=>'voitures',
|
||||
'Motos'=>'motos',
|
||||
'Caravaning'=>'caravaning',
|
||||
'Utilitaires'=>'utilitaires',
|
||||
'Équipement Auto'=>'equipement_auto',
|
||||
'Équipement Moto'=>'equipement_moto',
|
||||
'Équipement Caravaning'=>'equipement_caravaning',
|
||||
'Nautisme'=>'nautisme',
|
||||
'Équipement Nautisme'=>'equipement_nautisme'
|
||||
'Tous' => '1',
|
||||
'Voitures' => '2',
|
||||
'Motos' => '3',
|
||||
'Caravaning' => '4',
|
||||
'Utilitaires' => '5',
|
||||
'Equipement Auto' => '6',
|
||||
'Equipement Moto' => '44',
|
||||
'Equipement Caravaning' => '50',
|
||||
'Nautisme' => '7',
|
||||
'Equipement Nautisme' => '51'
|
||||
),
|
||||
'IMMOBILIER' => array(
|
||||
'Tous'=>'_immobilier_',
|
||||
'Ventes immobilières'=>'ventes_immobilieres',
|
||||
'Locations'=>'locations',
|
||||
'Colocations'=>'colocations',
|
||||
'Bureaux & Commerces'=>'bureaux_commerces'
|
||||
'Tous' => '8',
|
||||
'Ventes immobilières' => '9',
|
||||
'Locations' => '10',
|
||||
'Colocations' => '11',
|
||||
'Bureaux & Commerces' => '13'
|
||||
),
|
||||
'VACANCES' => array(
|
||||
'Tous'=>'_vacances_',
|
||||
'Location gîtes'=>'locations_gites',
|
||||
'Chambres d\'hôtes'=>'chambres_d_hotes',
|
||||
'Campings'=>'campings',
|
||||
'Hôtels'=>'hotels',
|
||||
'Hébergements insolites'=>'hebergements_insolites'
|
||||
'Tous' => '66',
|
||||
'Locations & Gîtes' => '12',
|
||||
'Chambres d\'hôtes' => '67',
|
||||
'Campings' => '68',
|
||||
'Hôtels' => '69',
|
||||
'Hébergements insolites' => '70'
|
||||
),
|
||||
'MULTIMEDIA' => array(
|
||||
'Tous'=>'_multimedia_',
|
||||
'Informatique'=>'informatique',
|
||||
'Consoles & Jeux vidéo'=>'consoles_jeux_video',
|
||||
'Image & Son'=>'image_son',
|
||||
'Téléphonie'=>'telephonie'
|
||||
'Tous' => '14',
|
||||
'Informatique' => '15',
|
||||
'Consoles & Jeux vidéo' => '43',
|
||||
'Image & Son' => '16',
|
||||
'Téléphonie' => '17'
|
||||
),
|
||||
'LOISIRS' => array(
|
||||
'Tous'=>'_loisirs_',
|
||||
'DVD / Films'=>'dvd_films',
|
||||
'CD / Musique'=>'cd_musique',
|
||||
'Livres'=>'livres',
|
||||
'Animaux'=>'animaux',
|
||||
'Vélos'=>'velos',
|
||||
'Sports & Hobbies'=>'sports_hobbies',
|
||||
'Instruments de musique'=>'instruments_de_musique',
|
||||
'Collection'=>'collection',
|
||||
'Jeux & Jouets'=>'jeux_jouets',
|
||||
'Vins & Gastronomie'=>'vins_gastronomie'
|
||||
'Tous' => '24',
|
||||
'DVD / Films' => '25',
|
||||
'CD / Musique' => '26',
|
||||
'Livres' => '27',
|
||||
'Animaux' => '28',
|
||||
'Vélos' => '55',
|
||||
'Sports & Hobbies' => '29',
|
||||
'Instruments de musique' => '30',
|
||||
'Collection' => '40',
|
||||
'Jeux & Jouets' => '41',
|
||||
'Vins & Gastronomie' => '48'
|
||||
),
|
||||
'MATÉRIEL PROFESSIONNEL'=>array(
|
||||
'Tous'=>'_materiel_professionnel_',
|
||||
'Matériel Agricole'=>'mateiel_agricole',
|
||||
'Transport - Manutention'=>'transport_manutention',
|
||||
'BTP - Chantier - Gros-œuvre'=>'btp_chantier_gros_oeuvre',
|
||||
'Outillage - Matériaux 2nd-œuvre'=>'outillage_materiaux_2nd_oeuvre',
|
||||
'Équipements Industriels'=>'equipement_industriels',
|
||||
'Restauration - Hôtellerie'=>'restauration_hotellerie',
|
||||
'Fournitures de Bureau'=>'fournitures_de_bureau',
|
||||
'Commerces & Marchés'=>'commerces_marches',
|
||||
'Matériel médical'=>'materiel_medical'
|
||||
'MATERIEL PROFESSIONNEL' => array(
|
||||
'Tous' => '56',
|
||||
'Matériel Agricole' => '57',
|
||||
'Transport - Manutention' => '58',
|
||||
'BTP - Chantier Gros-oeuvre' => '59',
|
||||
'Outillage - Matériaux 2nd-oeuvre' => '60',
|
||||
'Équipements Industriels' => '32',
|
||||
'Restauration - Hôtellerie' => '61',
|
||||
'Fournitures de Bureau' => '62',
|
||||
'Commerces & Marchés' => '63',
|
||||
'Matériel Médical' => '64'
|
||||
),
|
||||
'SERVICES' => array(
|
||||
'Tous'=>'_services_',
|
||||
'Prestations de services'=>'prestations_de_services',
|
||||
'Billetterie'=>'billetterie',
|
||||
'Évènements'=>'evenements',
|
||||
'Cours particuliers'=>'cours_particuliers',
|
||||
'Covoiturage'=>'covoiturage'
|
||||
'Tous' => '31',
|
||||
'Prestations de services' => '34',
|
||||
'Billetterie' => '35',
|
||||
'Evénements' => '49',
|
||||
'Cours particuliers' => '36',
|
||||
'Covoiturage' => '65'
|
||||
),
|
||||
'MAISON' => array(
|
||||
'Tous'=>'_maison_',
|
||||
'Ameublement'=>'ameublement',
|
||||
'Électroménager'=>'electromenager',
|
||||
'Arts de la table'=>'arts_de_la_table',
|
||||
'Décoration'=>'decoration',
|
||||
'Linge de maison'=>'linge_de_maison',
|
||||
'Bricolage'=>'bricolage',
|
||||
'Jardinage'=>'jardinage',
|
||||
'Vêtements'=>'vetements',
|
||||
'Chaussures'=>'chaussures',
|
||||
'Accessoires & Bagagerie'=>'accessoires_bagagerie',
|
||||
'Montres & Bijoux'=>'montres_bijoux',
|
||||
'Équipement bébé'=>'equipement_bebe',
|
||||
'Vêtements bébé'=>'vetements_bebe'
|
||||
'Tous' => '18',
|
||||
'Ameublement' => '19',
|
||||
'Electroménager' => '20',
|
||||
'Arts de la table' => '45',
|
||||
'Décoration' => '39',
|
||||
'Linge de maison' => '46',
|
||||
'Bricolage' => '21',
|
||||
'Jardinage' => '52',
|
||||
'Vêtements' => '22',
|
||||
'Chaussures' => '53',
|
||||
'Accessoires & Bagagerie' => '47',
|
||||
'Montres & Bijoux' => '42',
|
||||
'Equipement bébé' => '23',
|
||||
'Vêtements bébé' => '54',
|
||||
),
|
||||
'AUTRES'=>'autres'
|
||||
'AUTRES' => '37'
|
||||
)
|
||||
),
|
||||
'o' => array(
|
||||
'name' => 'Vendeur',
|
||||
'type' => 'list',
|
||||
'values' => array(
|
||||
'Tous' => '',
|
||||
'Particuliers' => 'private',
|
||||
'Professionnels' => 'pro',
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -138,48 +152,72 @@ class LeBonCoinBridge extends BridgeAbstract{
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$category=$this->getInput('c');
|
||||
if (empty($category)){
|
||||
$category='annonces';
|
||||
$params = array(
|
||||
'text' => $this->getInput('k'),
|
||||
'region' => $this->getInput('r'),
|
||||
'cities' => $this->getInput('cities'),
|
||||
'category' => $this->getInput('c'),
|
||||
'owner_type' => $this->getInput('o'),
|
||||
);
|
||||
|
||||
$url = self::URI . 'recherche/?' . http_build_query($params);
|
||||
$html = getContents($url)
|
||||
or returnServerError('Could not request LeBonCoin. Tried: ' . $url);
|
||||
|
||||
if(!preg_match('/^<script>window.FLUX_STATE[^\r\n]*/m', $html, $matches)) {
|
||||
returnServerError('Could not parse JSON in page content.');
|
||||
}
|
||||
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI.$category.'/offres/' . $this->getInput('r') . '/?'
|
||||
.'f=a&th=1&'
|
||||
.'q=' . urlencode($this->getInput('k'))
|
||||
) or returnServerError('Could not request LeBonCoin.');
|
||||
$clean_match = str_replace(
|
||||
array('</script>', '<script>window.FLUX_STATE = '),
|
||||
array('', ''),
|
||||
$matches[0]
|
||||
);
|
||||
$json = json_decode($clean_match);
|
||||
|
||||
$list = $html->find('.tabsContent', 0);
|
||||
if($list === NULL) {
|
||||
if($json->adSearch->data->total === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tags = $list->find('li');
|
||||
foreach($json->adSearch->data->ads as $element) {
|
||||
|
||||
foreach($tags as $element) {
|
||||
$item['title'] = $element->subject;
|
||||
$item['content'] = $element->body;
|
||||
$item['date'] = $element->index_date;
|
||||
$item['timestamp'] = strtotime($element->index_date);
|
||||
$item['uri'] = $element->url;
|
||||
$item['ad_type'] = $element->ad_type;
|
||||
$item['author'] = $element->owner->name;
|
||||
|
||||
$element = $element->find('a', 0);
|
||||
if(isset($element->location->city)) {
|
||||
|
||||
$item = array();
|
||||
$item['uri'] = $element->href;
|
||||
$title = html_entity_decode($element->getAttribute('title'));
|
||||
$content_image = $element->find('div.item_image', 0)->find('.lazyload', 0);
|
||||
$item['city'] = $element->location->city;
|
||||
$item['content'] .= ' -- ' . $element->location->city;
|
||||
|
||||
if($content_image !== NULL) {
|
||||
$content = '<img src="' . $content_image->getAttribute('data-imgsrc') . '" alt="thumbnail">';
|
||||
} else {
|
||||
$content = "";
|
||||
}
|
||||
$date = $element->find('aside.item_absolute', 0)->find('p.item_sup', 0);
|
||||
|
||||
$detailsList = $element->find('section.item_infos', 0);
|
||||
if(isset($element->location->zipcode)) {
|
||||
$item['zipcode'] = $element->location->zipcode;
|
||||
}
|
||||
|
||||
for($i = 0; $i <= 1; $i++) $content .= $detailsList->find('p.item_supp', $i)->plaintext;
|
||||
$price = $detailsList->find('h3.item_price', 0);
|
||||
$content .= $price === NULL ? '' : $price->plaintext;
|
||||
if(isset($element->price)) {
|
||||
|
||||
$item['price'] = $element->price[0];
|
||||
$item['content'] .= ' -- ' . current($element->price) . '€';
|
||||
|
||||
}
|
||||
|
||||
if(isset($element->images->urls)) {
|
||||
|
||||
$item['thumbnail'] = $element->images->thumb_url;
|
||||
$item['enclosures'] = array();
|
||||
|
||||
foreach($element->images->urls as $image) {
|
||||
$item['enclosures'][] = $image;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$item['title'] = $title;
|
||||
$item['content'] = $content . $date;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class LeMondeInformatiqueBridge extends FeedExpander {
|
||||
|
||||
const MAINTAINER = "ORelio";
|
||||
const NAME = "Le Monde Informatique";
|
||||
const URI = "http://www.lemondeinformatique.fr/";
|
||||
const MAINTAINER = 'ORelio';
|
||||
const NAME = 'Le Monde Informatique';
|
||||
const URI = 'http://www.lemondeinformatique.fr/';
|
||||
const CACHE_TIMEOUT = 1800; // 30min
|
||||
const DESCRIPTION = "Returns the newest articles.";
|
||||
const DESCRIPTION = 'Returns the newest articles.';
|
||||
|
||||
public function collectData(){
|
||||
$this->collectExpandableDatas(self::URI . 'rss/rss.xml', 10);
|
||||
@@ -15,28 +15,30 @@ class LeMondeInformatiqueBridge extends FeedExpander {
|
||||
$item = parent::parseItem($newsItem);
|
||||
$article_html = getSimpleHTMLDOMCached($item['uri'])
|
||||
or returnServerError('Could not request LeMondeInformatique: ' . $item['uri']);
|
||||
$item['content'] = $this->CleanArticle($article_html->find('div#article', 0)->innertext);
|
||||
$item['content'] = $this->cleanArticle($article_html->find('div#article', 0)->innertext);
|
||||
$item['title'] = $article_html->find('h1.cleanprint-title', 0)->plaintext;
|
||||
return $item;
|
||||
}
|
||||
|
||||
function StripCDATA($string) {
|
||||
private function stripCDATA($string){
|
||||
$string = str_replace('<![CDATA[', '', $string);
|
||||
$string = str_replace(']]>', '', $string);
|
||||
return $string;
|
||||
}
|
||||
|
||||
function StripWithDelimiters($string, $start, $end) {
|
||||
private function stripWithDelimiters($string, $start, $end){
|
||||
while(strpos($string, $start) !== false) {
|
||||
$section_to_remove = substr($string, strpos($string, $start));
|
||||
$section_to_remove = substr($section_to_remove, 0, strpos($section_to_remove, $end) + strlen($end));
|
||||
$string = str_replace($section_to_remove, '', $string);
|
||||
} return $string;
|
||||
}
|
||||
|
||||
function CleanArticle($article_html) {
|
||||
$article_html = $this->StripWithDelimiters($article_html, '<script', '</script>');
|
||||
$article_html = $this->StripWithDelimiters($article_html, '<h1 class="cleanprint-title"', '</h1>');
|
||||
return $string;
|
||||
}
|
||||
|
||||
private function cleanArticle($article_html){
|
||||
$article_html = $this->stripWithDelimiters($article_html, '<script', '</script>');
|
||||
$article_html = $this->stripWithDelimiters($article_html, '<h1 class="cleanprint-title"', '</h1>');
|
||||
return $article_html;
|
||||
}
|
||||
}
|
||||
|
@@ -42,10 +42,10 @@ class LegifranceJOBridge extends BridgeAbstract{
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
or $this->returnServer('Unable to download ' . self::URI);
|
||||
|
||||
$this->author=trim($html->find('h2.title',0)->plaintext);
|
||||
$this->author = trim($html->find('h2.titleJO', 0)->plaintext);
|
||||
$uri = $html->find('h2.titleELI', 0)->plaintext;
|
||||
$this->uri = trim(substr($uri, strpos($uri, 'https')));
|
||||
$this->timestamp=strtotime(substr($this->uri,strpos($this->uri,'eli/jo/')+strlen('eli/jo/')));
|
||||
$this->timestamp = strtotime(substr($this->uri, strpos($this->uri, 'eli/jo/') + strlen('eli/jo/'), -5));
|
||||
|
||||
foreach($html->find('h3') as $section) {
|
||||
$subsections = $section->nextSibling()->find('h4');
|
||||
@@ -66,5 +66,3 @@ class LegifranceJOBridge extends BridgeAbstract{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class LesJoiesDuCodeBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "superbaillot.net";
|
||||
const NAME = "Les Joies Du Code";
|
||||
const URI = "http://lesjoiesducode.fr/";
|
||||
const MAINTAINER = 'superbaillot.net';
|
||||
const NAME = 'Les Joies Du Code';
|
||||
const URI = 'http://lesjoiesducode.fr/';
|
||||
const CACHE_TIMEOUT = 7200; // 2h
|
||||
const DESCRIPTION = "LesJoiesDuCode";
|
||||
const DESCRIPTION = 'LesJoiesDuCode';
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM(self::URI)
|
||||
@@ -22,21 +22,19 @@ class LesJoiesDuCodeBridge extends BridgeAbstract{
|
||||
// retrieve .gif instead of static .jpg
|
||||
$images = $temp->find('p img');
|
||||
foreach($images as $image) {
|
||||
$img_src = str_replace(".jpg",".gif",$image->src);
|
||||
$img_src = str_replace('.jpg', '.gif', $image->src);
|
||||
$image->src = $img_src;
|
||||
}
|
||||
$content = $temp->innertext;
|
||||
|
||||
$auteur = $temp->find('i', 0);
|
||||
$pos = strpos($auteur->innertext, "by");
|
||||
$pos = strpos($auteur->innertext, 'by');
|
||||
|
||||
if($pos > 0)
|
||||
{
|
||||
$auteur = trim(str_replace("*/", "", substr($auteur->innertext, ($pos + 2))));
|
||||
if($pos > 0) {
|
||||
$auteur = trim(str_replace('*/', '', substr($auteur->innertext, ($pos + 2))));
|
||||
$item['author'] = $auteur;
|
||||
}
|
||||
|
||||
|
||||
$item['content'] .= trim($content);
|
||||
$item['uri'] = $url;
|
||||
$item['title'] = trim($titre);
|
||||
|
@@ -12,11 +12,11 @@ class LichessBridge extends FeedExpander {
|
||||
|
||||
protected function parseItem($newsItem){
|
||||
$item = parent::parseItem($newsItem);
|
||||
$item['content'] = $this->retrieve_lichess_post($item['uri']);
|
||||
$item['content'] = $this->retrieveLichessPost($item['uri']);
|
||||
return $item;
|
||||
}
|
||||
|
||||
private function retrieve_lichess_post($blog_post_uri){
|
||||
private function retrieveLichessPost($blog_post_uri){
|
||||
$blog_post_html = getSimpleHTMLDOMCached($blog_post_uri);
|
||||
$blog_post_div = $blog_post_html->find('#lichess_blog', 0);
|
||||
|
||||
|
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
class LinkedInCompanyBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "regisenguehard";
|
||||
const NAME = "LinkedIn Company";
|
||||
const URI = "https://www.linkedin.com/";
|
||||
const MAINTAINER = 'regisenguehard';
|
||||
const NAME = 'LinkedIn Company';
|
||||
const URI = 'https://www.linkedin.com/';
|
||||
const CACHE_TIMEOUT = 21600; //6
|
||||
const DESCRIPTION = "Returns most recent actus from Company on LinkedIn. (https://www.linkedin.com/company/<strong style=\"font-weight:bold;\">apple</strong>)";
|
||||
const DESCRIPTION = 'Returns most recent actus from Company on LinkedIn.
|
||||
(https://www.linkedin.com/company/<strong style=\"font-weight:bold;\">apple</strong>)';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'c' => array(
|
||||
|
@@ -3,9 +3,9 @@ require_once('MoebooruBridge.php');
|
||||
|
||||
class LolibooruBridge extends MoebooruBridge {
|
||||
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Lolibooru";
|
||||
const URI = "https://lolibooru.moe/";
|
||||
const DESCRIPTION = "Returns images from given page and tags";
|
||||
const MAINTAINER = 'mitsukarenai';
|
||||
const NAME = 'Lolibooru';
|
||||
const URI = 'https://lolibooru.moe/';
|
||||
const DESCRIPTION = 'Returns images from given page and tags';
|
||||
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
class MangareaderBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = "logmanoriginal";
|
||||
const NAME = "Mangareader Bridge";
|
||||
const URI = "http://www.mangareader.net/";
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const NAME = 'Mangareader Bridge';
|
||||
const URI = 'http://www.mangareader.net';
|
||||
const CACHE_TIMEOUT = 10800; // 3h
|
||||
const DESCRIPTION = "Returns the latest updates, popular mangas or manga updates (new chapters)";
|
||||
const DESCRIPTION = 'Returns the latest updates, popular mangas or manga updates (new chapters)';
|
||||
|
||||
const PARAMETERS = array(
|
||||
'Get latest updates' => array(),
|
||||
@@ -95,13 +95,13 @@ class MangareaderBridge extends BridgeAbstract {
|
||||
switch($this->queriedContext) {
|
||||
case 'Get latest updates':
|
||||
$this->request = 'Latest updates';
|
||||
$this->get_latest_updates($xpath);
|
||||
$this->getLatestUpdates($xpath);
|
||||
break;
|
||||
case 'Get popular mangas':
|
||||
// Find manga name within "Popular mangas for ..."
|
||||
$pagetitle = $xpath->query(".//*[@id='bodyalt']/h1")->item(0)->nodeValue;
|
||||
$this->request = substr($pagetitle, 0, strrpos($pagetitle, " -"));
|
||||
$this->get_popular_mangas($xpath);
|
||||
$this->request = substr($pagetitle, 0, strrpos($pagetitle, ' -'));
|
||||
$this->getPopularMangas($xpath);
|
||||
break;
|
||||
case 'Get manga updates':
|
||||
$limit = $this->getInput('limit');
|
||||
@@ -113,20 +113,20 @@ class MangareaderBridge extends BridgeAbstract {
|
||||
->item(0)
|
||||
->nodeValue;
|
||||
|
||||
$this->get_manga_updates($xpath, $limit);
|
||||
$this->getMangaUpdates($xpath, $limit);
|
||||
break;
|
||||
}
|
||||
|
||||
// Return some dummy-data if no content available
|
||||
if(empty($this->items)) {
|
||||
$item = array();
|
||||
$item['content'] = "<p>No updates available</p>";
|
||||
$item['content'] = '<p>No updates available</p>';
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
private function get_latest_updates($xpath){
|
||||
private function getLatestUpdates($xpath){
|
||||
// Query each item (consists of Manga + chapters)
|
||||
$nodes = $xpath->query("//*[@id='latestchapters']/table//td");
|
||||
|
||||
@@ -143,19 +143,18 @@ class MangareaderBridge extends BridgeAbstract {
|
||||
$item['title'] = htmlspecialchars($manga->nodeValue);
|
||||
|
||||
// Add each chapter to the feed
|
||||
$item['content'] = "";
|
||||
$item['content'] = '';
|
||||
|
||||
foreach ($chapters as $chapter) {
|
||||
if($item['content'] <> ""){
|
||||
$item['content'] .= "<br>";
|
||||
if($item['content'] <> '') {
|
||||
$item['content'] .= '<br>';
|
||||
}
|
||||
$item['content'] .=
|
||||
"<a href='"
|
||||
$item['content'] .= "<a href='"
|
||||
. self::URI
|
||||
. htmlspecialchars($chapter->getAttribute('href'))
|
||||
. "'>"
|
||||
. htmlspecialchars($chapter->nodeValue)
|
||||
. "</a>";
|
||||
. '</a>';
|
||||
}
|
||||
|
||||
$this->items[] = $item;
|
||||
@@ -163,7 +162,7 @@ class MangareaderBridge extends BridgeAbstract {
|
||||
}
|
||||
}
|
||||
|
||||
private function get_popular_mangas($xpath){
|
||||
private function getPopularMangas($xpath){
|
||||
// Query all mangas
|
||||
$mangas = $xpath->query("//*[@id='mangaresults']/*[@class='mangaresultitem']");
|
||||
|
||||
@@ -201,7 +200,7 @@ EOD;
|
||||
}
|
||||
}
|
||||
|
||||
private function get_manga_updates($xpath, $limit){
|
||||
private function getMangaUpdates($xpath, $limit){
|
||||
$query = "(.//*[@id='listing']//tr)[position() > 1]";
|
||||
|
||||
if($limit !== -1) {
|
||||
@@ -212,13 +211,13 @@ EOD;
|
||||
|
||||
foreach ($chapters as $chapter) {
|
||||
$item = array();
|
||||
$item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter)
|
||||
$item['title'] = htmlspecialchars($xpath->query('td[1]', $chapter)
|
||||
->item(0)
|
||||
->nodeValue);
|
||||
$item['uri'] = self::URI . $xpath->query("td[1]/a", $chapter)
|
||||
$item['uri'] = self::URI . $xpath->query('td[1]/a', $chapter)
|
||||
->item(0)
|
||||
->getAttribute('href');
|
||||
$item['timestamp'] = strtotime($xpath->query("td[2]", $chapter)
|
||||
$item['timestamp'] = strtotime($xpath->query('td[2]', $chapter)
|
||||
->item(0)
|
||||
->nodeValue);
|
||||
array_unshift($this->items, $item);
|
||||
@@ -228,24 +227,23 @@ EOD;
|
||||
public function getURI(){
|
||||
switch($this->queriedContext) {
|
||||
case 'Get latest updates':
|
||||
$path = "latest";
|
||||
$path = 'latest';
|
||||
break;
|
||||
case 'Get popular mangas':
|
||||
$path = "popular";
|
||||
if($this->getInput('category') !== "all"){
|
||||
$path .= "/" . $this->getInput('category');
|
||||
$path = 'popular';
|
||||
if($this->getInput('category') !== 'all') {
|
||||
$path .= '/' . $this->getInput('category');
|
||||
}
|
||||
break;
|
||||
case 'Get manga updates':
|
||||
$path = $this->getInput('path');
|
||||
break;
|
||||
default: return parent::getURI();
|
||||
}
|
||||
return self::URI . $path;
|
||||
return self::URI . '/' . $path;
|
||||
}
|
||||
|
||||
|
||||
public function getName(){
|
||||
return (!empty($this->request) ? $this->request . ' - ' : '') . 'Mangareader Bridge';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -3,9 +3,9 @@ require_once('Shimmie2Bridge.php');
|
||||
|
||||
class MilbooruBridge extends Shimmie2Bridge {
|
||||
|
||||
const MAINTAINER = "mitsukarenai";
|
||||
const NAME = "Milbooru";
|
||||
const URI = "http://sheslostcontrol.net/moe/shimmie/";
|
||||
const DESCRIPTION = "Returns images from given page";
|
||||
const MAINTAINER = 'mitsukarenai';
|
||||
const NAME = 'Milbooru';
|
||||
const URI = 'http://sheslostcontrol.net/moe/shimmie/';
|
||||
const DESCRIPTION = 'Returns images from given page';
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user