Fixing scan when created date is null.
This commit is contained in:
parent
ca6c232f4b
commit
238acb3d0c
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
torrents_csv="`pwd`/../torrents.csv"
|
torrents_csv="`pwd`/../torrents.csv"
|
||||||
scanned_out="`pwd`/../infohashes_scanned.txt"
|
scanned_out="`pwd`/../infohashes_scanned.txt"
|
||||||
tmp_torrent_dir="`pwd`/../tmp_torrents"
|
tmp_torrent_dir="`pwd`/../tmp_torrents-$RANDOM"
|
||||||
torrent_files_json="`pwd`/../torrent_files.json"
|
torrent_files_json="`pwd`/../torrent_files.json"
|
||||||
touch $scanned_out
|
touch $scanned_out
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ cd $tmp_torrent_dir
|
||||||
ls|parallel -n100 mkdir {#}\;mv {} {#}
|
ls|parallel -n100 mkdir {#}\;mv {} {#}
|
||||||
|
|
||||||
for tmp_torrent_dir_sub in *; do
|
for tmp_torrent_dir_sub in *; do
|
||||||
echo "sub dir: $tmp_torrent_dir_sub"
|
echo "sub dir:$tmp_torrent_dir/$tmp_torrent_dir_sub"
|
||||||
find $tmp_torrent_dir_sub -type f -exec basename {} .torrent \; > names.out
|
find $tmp_torrent_dir_sub -type f -exec basename {} .torrent \; > names.out
|
||||||
|
|
||||||
# Delete null torrents from the temp dir
|
# Delete null torrents from the temp dir
|
||||||
|
@ -54,11 +54,12 @@ for tmp_torrent_dir_sub in *; do
|
||||||
torrent-tracker-health --torrent "$tmp_torrent_dir_sub"/ > health.out
|
torrent-tracker-health --torrent "$tmp_torrent_dir_sub"/ > health.out
|
||||||
|
|
||||||
# Convert the json results to csv format
|
# Convert the json results to csv format
|
||||||
results=$(jq -r '.results | map([.hash, .name, .length, (.created | .[0:16] | strptime("%Y-%m-%dT%H:%M") | mktime), .seeders, .leechers, .completed, (now | floor)] | join(";")) | join("\n")' health.out)
|
# Created is sometimes null, and a weird date
|
||||||
|
results=$(jq -r '.results[] | select (.created != null ) | [.hash, .name, .length, (.created | .[0:16] | strptime("%Y-%m-%dT%H:%M") | mktime), .seeders, .leechers, .completed, (now | floor)] | join(";")' health.out)
|
||||||
# If there are no results
|
# If there are no results
|
||||||
if [ -z "$results" ]; then
|
if [ -z "$results" ]; then
|
||||||
echo "There were no results for some reason."
|
echo "There were no results for some reason."
|
||||||
|
cat health.out
|
||||||
else
|
else
|
||||||
echo "Torrents.csv updated with new torrents."
|
echo "Torrents.csv updated with new torrents."
|
||||||
# Update the torrents.csv and infohashes scanned file
|
# Update the torrents.csv and infohashes scanned file
|
||||||
|
|
Loading…
Reference in New Issue