Fix debug, clear data structure, add images

This commit is contained in:
poka 2020-03-22 21:11:01 +01:00
parent 2a1166493f
commit 18ce1b10b8
6 changed files with 45 additions and 20 deletions

4
.gitignore vendored
View File

@ -1,6 +1,4 @@
data/files/*
data/torrents/*
data/nfo/*
data/*
__pycache__/
yggcrawl/__pycache__/
yggcrawl/__init__.pyc

View File

@ -29,6 +29,7 @@ from yggtorrentscraper import set_yggtorrent_tld
set_yggtorrent_tld("se")
name = ' '.join(sys.argv[1:])
print("ok")
# Search torrent name
research = os.popen('./lib/scrabash.sh search --best=true ' + name).read()
print(colored(research, 'yellow'))

View File

View File

@ -17,37 +17,56 @@ search() {
[[ $best == true ]] && echo "$result" | head -n1 || echo "$result"
}
get_images() {
[[ -z $name ]] && echo "Please choose a torrent url" && exit 1
idTorrent=$(echo "$name" | awk -F '/' '{print $NF}' | awk -F '-' '{ print $1 }')
mkdir $idTorrent
cd $idTorrent
wget -q -r -np -nd -k "$1"
url=$(cat * | awk -v RS=' ' '/.jpg/' | awk -F '"' '{ print $2 }' | head -n1)
curl -s -O $url
}
get_details() {
result=$(./lib/py/scrapactions.py $1 $name | grep -v "Login success")
# echo "$result"
idTorrent=$(echo "$name" | awk -F '/' '{print $NF}' | awk -F '-' '{ print $1 }')
if [[ $print == true ]]; then
[[ ! -d data/nfo/$idTorrent ]] && mkdir data/nfo/$idTorrent
echo "$result" > ./data/nfo/$idTorrent/info.txt
[[ ! -d data/$idTorrent ]] && mkdir data/$idTorrent
cd data/$idTorrent
echo "$result" > info.txt
torrentName=$(echo "$result" | grep -w "Name :" | awk -F ": " '{ print $2 }')
torrentUrl=$(echo "$result" | grep -w "Url :" | awk -F ": " '{ print $2 }')
torrentSize=$(echo "$result" | grep -w "Size :" | awk -F ": " '{ print $2 }')
if [[ $torrentSize =~ "Go" ]]; then
unity="Go"
Url=$(echo "$result" | grep -w "Url :" | awk -F ": " '{ print $2 }')
Size=$(echo "$result" | grep -w "Size :" | awk -F ": " '{ print $2 }')
Uploader=$(echo "$result" | grep -w "Uploader :" | awk -F ": " '{ print $2 }')
Files=$(echo "$result" | grep -w "file_name :" | awk -F ": " '{ print $2 }' | wc -l)
if [[ $Size =~ "Go" ]]; then
Unity="Go"
else
unity="Mo"
Unity="Mo"
fi
torrentSize=$(echo "$torrentSize" | tr -d 'Go')
torrentSeeders=$(echo "$result" | grep -w "Seeders :" | awk -F ": " '{ print $2 }')
Size=$(echo "$Size" | tr -d 'Go')
Seeders=$(echo "$result" | grep -w "Seeders :" | awk -F ": " '{ print $2 }')
echo "$idTorrent"
echo "Name = '$torrentName'
Url = '$torrentUrl'
Size = $torrentSize
Unity = '$unity'
Seeders = $torrentSeeders
ID = $idTorrent" > ./data/nfo/$idTorrent/db.py
echo -e "Name = '$torrentName'\nUrl = '$Url'\nSize = $Size\nUnity = '$Unity'\nID = $idTorrent\nUploader = $Uploader\nFiles = $Files" > db.py
# Get image
[[ ! -d img ]] && mkdir img && cd img
url=$(wget -qO- -np -nd $name | awk -v RS=' ' '/.jpg/' | awk -F '"' '{ print $2 }' | head -n1)
curl -s -O $url
fi
}
$1 $1
$1 $name
[[ $err == 1 ]] && exit 1 || exit 0

8
requirements.txt Normal file
View File

@ -0,0 +1,8 @@
requests
json
sys
subprocess
login
time
re

View File

@ -162,7 +162,6 @@ class YggTorrentScraper:
def search(self, parameters):
search_url = create_search_url(parameters)
torrents_url = self.get_torrents_url(search_url, parameters)
return torrents_url