mirror of
https://github.com/thewesker/greptweet.git
synced 2025-12-20 12:11:05 -05:00
Get rid of nodejs/jsontool dependency
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
# vim: set ts=4 sw=4
|
# vim: set ts=4 sw=4
|
||||||
|
# apache_setenv('no-gzip', '1');
|
||||||
exec 2>&1
|
exec 2>&1
|
||||||
cat <<END
|
cat <<END
|
||||||
Cache-Control: no-cache
|
Cache-Control: no-cache
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ then
|
|||||||
test "$2" && since='&max_id='$(tail -n1 $1.txt | cut -d'|' -f1) # use max_id to get older tweets
|
test "$2" && since='&max_id='$(tail -n1 $1.txt | cut -d'|' -f1) # use max_id to get older tweets
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while urlargs="screen_name=${1}&count=200&page=${page}${since}&include_rts=1&trim_user=0&include_entities=1"; echo $urlargs; $(dirname $0)/oauth.php $urlargs |
|
while urlargs="screen_name=${1}&count=200&page=${page}${since}&include_rts=1&trim_user=0"; echo $urlargs; $(dirname $0)/oauth.php $urlargs |
|
||||||
json -d '|' -a id_str created_at -e 'this.t = this.text.replace(/\s*\n\s*/g, " "); this.entities.urls.forEach(function (u) { this.t = this.t.replace(u.url, u.expanded_url) });' t > $temp2; test $(wc -l < $temp2) -gt 0;
|
$(dirname $0)/json-to-text.php > $temp2; test $(wc -l < $temp2) -gt 0;
|
||||||
do
|
do
|
||||||
|
|
||||||
#cat temp2
|
#cat temp2
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ if (user) { window.location.replace("/u/" + user); }
|
|||||||
<p>Super-geeks please <a href="https://github.com/kaihendry/Greptweet">report issues and contribute on Github</a> :)</p>
|
<p>Super-geeks please <a href="https://github.com/kaihendry/Greptweet">report issues and contribute on Github</a> :)</p>
|
||||||
<p>Active accounts: <!--#include virtual="active-users.txt" --></p>
|
<p>Active accounts: <!--#include virtual="active-users.txt" --></p>
|
||||||
<p>Version: <a href=https://github.com/kaihendry/Greptweet/commit/<!--#include virtual="version.txt" -->><!--#include virtual="version.txt" --></a></p>
|
<p>Version: <a href=https://github.com/kaihendry/Greptweet/commit/<!--#include virtual="version.txt" -->><!--#include virtual="version.txt" --></a></p>
|
||||||
<p>Backup: <code>rsync -artzv --include "*/" --include "*.txt" --exclude "*" --exclude "tweets.txt" greptweet.com::greptweet .</code> - go get your data!</p>
|
<p>Backup: <code>rsync -artzv --include "*/" --include "*.txt" --exclude "*" --exclude "tweets.txt" greptweet.com::greptweet .</code></p>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
29
json-to-text.php
Executable file
29
json-to-text.php
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env php
|
||||||
|
<?php
|
||||||
|
$json_string = file_get_contents("php://stdin");
|
||||||
|
$foo = json_decode($json_string);
|
||||||
|
echo count($foo);
|
||||||
|
for ($i=0; $i<count($foo); $i++){
|
||||||
|
echo $foo[$i]->id_str . "|";
|
||||||
|
echo $foo[$i]->created_at . "|";
|
||||||
|
$tweet = $foo[$i]->text;
|
||||||
|
if (!empty($foo[$i]->entities->urls)) {
|
||||||
|
foreach($foo[$i]->entities->urls as $u) {
|
||||||
|
//print_r($u->url);
|
||||||
|
////print_r($u->expanded_url);
|
||||||
|
$tweet = str_replace($u->url,$u->expanded_url,$tweet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!empty($foo[$i]->entities->media)) {
|
||||||
|
foreach($foo[$i]->entities->media as $m) {
|
||||||
|
//print_r($u->url);
|
||||||
|
////print_r($u->expanded_url);
|
||||||
|
$tweet = str_replace($m->url,$m->media_url,$tweet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo $tweet . "\n";
|
||||||
|
}
|
||||||
|
//print_r($foo);
|
||||||
|
//$pp = json_encode($foo, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
||||||
|
//echo $pp;
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user