-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopcorn.lib
More file actions
executable file
·108 lines (89 loc) · 3 KB
/
popcorn.lib
File metadata and controls
executable file
·108 lines (89 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: popcorn.lib
# Created: Wednesday, 2023/08/30 - 20:23:49
# Author.: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Sunday, 2025/01/19 - 12:35:25
# Modified By..: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.0.4.135
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
# ############################################################################
# HISTORY:
#
_xLIB_POPCORN_=true
# create app data folder
xsetHome
# set default player
player=mpv
_history_file=$APP_HOME/search.txt
_PDATA=~/popcorn
# used commands
_peerflix="peerflix '<link>' --all --list --subtitles --no-quit --$player --"
_pirateget="pirate-get -C \"<peerflix>\" \"<search>\""
_run_cmd=''
saveHistory(){
xrequirements mdate
echo "$(mdate --us -f):$search" >> "$_history_file"
}
pSearch(){
[ -z "$search" ] && search="$@"
# save search in history
saveHistory
# prepare 'pirete-get/peerflix' commands
_peerflix=${_peerflix//<link>/%s}
_pirateget="pirate-get -C \"$_peerflix\" \"$search\""
# update command
_run_cmd=${_pirateget//<peerfliex>/$_peerflix}
_run_cmd=${_pirateget//<search>/$search}
# validate selected player
xrequirements "$player"
}
pWeb(){
xrequirements docker
docker volume create \
--name popcorn-data type=none \
--opt device=/tmp/torrent-stream \
--opt o=bind
docker run -p 9000:9000 -p 6881:6881 -p 6881:6881/udp \
--rm -it \
--mount source=popcorn-data,target=/tmp/torrent-stream \
--name porpcorn-web \
asapach/peerflix-server
# -v /tmp/torrent-stream/:/tmp/torrent-stream/ \
# --mount type=bind,source="/tmp/torrent-stream"/target,target=/tmp/torrent-stream \
exit
}
pMagnet(){
# magnet is a valid link?
if [[ "$magnet" =~ "magnet:?xt=" ]]; then
link=${magnet^^}
else
# get magnet by string/folder/file name
link="magnet:?xt=urn:btih:${magnet//.torrent}"
fi
# prepare command
_run_cmd=${_peerflix//<link>/${link}}
}
pHistory(){
cat "$_history_file"
}
pStatus(){
xrequirements xhr ls wc du tail find grep aw column
div=$(xhr 1 -s 40)
echo -e "\n${CYAN}${div}\n#\t${APP} status\n${div}${RESET}"
output+="\n${YELLOW}torrents${RESET}:;$(ls -l $_PDATA | wc -l)"
output+="\n${YELLOW} \`-> downloaded:${RESET};$(find -maxdepth 1 -type d | wc -l)"
output+="\n${YELLOW} \`-> files.....:${RESET};$(ls -l $_PDATA | grep '.torrent' | wc -l)"
output+="\n${YELLOW}storage${RESET}.:;$_PDATA (${RED}$(du -h $_PDATA | tail -n1 | aw 1)${RESET})"
echo -e "$output" | column -t -s ';'
echo -e "${CYAN}${div}\n#\tend\n${div}${RESET}"
}
runApp(){
echo "$_run_cmd" && eval "$_run_cmd"
}