Skip to content

Commit a24bed3

Browse files
committed
Initialization of the repository for TraktForVLC 2.x
The new structure for TraktForVLC 2.x includes a Lua VLC module that will take care of following what is happening on the VLC side, while a helper Python script is provided to perform all the tasks that the VLC embedded Lua does not allow to do. TraktForVLC 2.x includes the following features: - Automatically set the watching status for movies and series - Automatically scrobble movies and series - Identify movies and series using a combination of APIs from OpenSubtitles, IMDB, TheTVDB and TMDB - Allow for offline save of movies and series scrobble status for late scrobble when an internet connection is found - Simple installation/update/uninstallation process - Automatic release of binaries for multiple OS (Linux, MacOS, Windows) for new releases, including the 'latest' tag that will keep up with the master branch Related to: #88 Signed-off-by: Raphaël Beamonte <[email protected]>
0 parents  commit a24bed3

24 files changed

+7913
-0
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Python files
2+
*.py[ocd]
3+
4+
## generic files to ignore
5+
*~
6+
*.lock
7+
*.DS_Store
8+
*.swp
9+
*.out
10+
11+
# TraktForVLC files
12+
*.luac
13+
build/
14+
dist/

.travis.yml

Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
language: python
2+
3+
branches:
4+
except:
5+
- latest
6+
- latest-tmp
7+
8+
matrix:
9+
fast_finish: true
10+
include:
11+
- os: linux
12+
python: 2.7
13+
- os: osx
14+
language: generic
15+
env: PYTHON=2.7.14
16+
17+
env:
18+
global:
19+
- PIPENV=9.0.3
20+
- secure: "CnchGXzH12uHNHwVeSdfyi/UBoHONNogxVaM+fIzcZXadiK3mm6mnjoBSXiFabNAgmMr20BHZ5OSB8qZLX5L0jMxrH3zfvlTUFivibL+IHAqPC/Jt1EpABDxbE+BMLVcpJBOVztDpACNDomnVX1X+mLhG2lbcD0x/XlZJugpB68="
21+
22+
before_install:
23+
# Need to disable the boto configuration before starting a sudo-enabled
24+
# build in Travis, or the tests will fail (as one of the modules loads
25+
# boto)
26+
- export BOTO_CONFIG=/dev/null
27+
# If we did not define the python version in the environment, set it as
28+
# being the one provided by Travis
29+
- if [ -z "${PYTHON}" ]; then
30+
PYTHON="${TRAVIS_PYTHON_VERSION}";
31+
fi
32+
# If we are on OSX, we need to devine a number of aliases for GNU commands,
33+
# as well as print the OSX software information
34+
- if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
35+
sw_vers;
36+
function sort() { $(which gsort) "$@"; };
37+
function timeout() { $(which gtimeout) "$@"; };
38+
export HOMEBREW_NO_AUTO_UPDATE=1;
39+
brew install gnu-sed --with-default-names;
40+
fi
41+
# If we are on pypy, determine which is the latest version by using the
42+
# bitbucket's API on pypy's repository
43+
- if [[ "${PYTHON}" =~ ^pypy ]]; then
44+
if [ "${PYTHON}" == "pypy" ]; then
45+
PYTHON=pypy2;
46+
fi;
47+
PYTHON=$(
48+
curl "https://api.bitbucket.org/2.0/repositories/pypy/pypy/refs/tags" 2>/dev/null |
49+
grep -oE "release-${PYTHON}[a-zA-Z0-9._-]*" |
50+
grep -- '-v' |
51+
sed -e 's/^release-//g' -e 's/\-v/\-/g' |
52+
sort -t'-' -k1,1Vr -k2,2Vr -u |
53+
head -n1
54+
);
55+
if [ -z "${PYTHON}" ]; then
56+
echo "ERROR - No PYPY version found.";
57+
exit 1;
58+
fi;
59+
echo "PyPy version - $PYTHON";
60+
fi
61+
# If we are on OSX, or if we want to use pypy, we need to install the
62+
# version of python we want. We are going to use pyenv for that, that will
63+
# take care of downloading and compiling python as needed.
64+
- if [[ "${TRAVIS_OS_NAME}" == "osx" ]] || [[ "${PYTHON}" =~ ^pypy ]]; then
65+
set -x;
66+
67+
rm -rf ~/.pyenv;
68+
69+
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
70+
export PYTHON_CONFIGURE_OPTS="--enable-framework";
71+
else
72+
export PYTHON_CONFIGURE_OPTS="--enable-shared";
73+
fi;
74+
75+
git clone --depth 1 https://github.com/pyenv/pyenv ~/.pyenv;
76+
PYENV_ROOT="$HOME/.pyenv";
77+
PATH="$PYENV_ROOT/bin:$PATH";
78+
eval "$(pyenv init -)";
79+
80+
pyenv install ${PYTHON} || exit 1;
81+
pyenv global ${PYTHON} || exit 1;
82+
83+
pyenv rehash;
84+
export PATH=$(python -c "import site, os; print(os.path.join(site.USER_BASE, 'bin'))"):$PATH;
85+
python -m pip install --user pipenv==${PIPENV};
86+
87+
echo $PATH;
88+
89+
set +x;
90+
else
91+
pip install pipenv==${PIPENV};
92+
fi
93+
# Print Python version
94+
- python --version
95+
- pipenv --version
96+
# Install all dependencies
97+
- python --version; which python
98+
- echo $PATH; pipenv install --dev
99+
# If the build should lead to a deployment, check that the tag is valid,
100+
# else, check what the current version will be
101+
- if [ -n "${TRAVIS_TAG}" ]; then
102+
pipenv run ./version.py check-tag --tag=${TRAVIS_TAG} &&
103+
environment=$(pipenv run ./version.py environment --version=${TRAVIS_TAG}) &&
104+
eval "$environment";
105+
else
106+
environment=$(pipenv run ./version.py environment) &&
107+
eval "$environment";
108+
fi &&
109+
printenv | grep '^TRAKT_VERSION' | sort
110+
# Set the binary name
111+
- TRAKT_HELPER_BIN=$(echo "TraktForVLC_${TRAKT_VERSION}_${TRAVIS_OS_NAME}" | sed -r 's/[^a-zA-Z0-9_.-]+/./g')
112+
# Install VLC
113+
- if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
114+
brew cask install vlc;
115+
else
116+
sudo apt-get install -y vlc;
117+
fi
118+
# Print VLC version
119+
- vlc --version
120+
121+
install:
122+
# Set the version in the Python and LUA scripts
123+
- pipenv run ./version.py set --version=${TRAKT_VERSION}
124+
# Compile the Lua scripts
125+
- vlc -I luaintf --lua-intf luac
126+
--lua-config 'luac={input="trakt.lua",output="trakt.luac"}'
127+
# Then prepare the binary file
128+
- pipenv run pyinstaller
129+
--onedir --onefile
130+
--name=${TRAKT_HELPER_BIN}
131+
--hidden-import=concurrent.futures
132+
--add-data=trakt.luac:.
133+
--console trakt_helper.py
134+
# Test the binary by first checking if the --version command returns properly
135+
- dist/${TRAKT_HELPER_BIN} --version
136+
# Then print the help message
137+
- dist/${TRAKT_HELPER_BIN} --help
138+
139+
script:
140+
# Prepare the variables to know where to check for the installation
141+
- if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
142+
CONFIG="${HOME}/Library/Application Support/org.videolan.vlc";
143+
LUA_USER="${CONFIG}/lua";
144+
LUA_SYSTEM="/Applications/VLC.app/Contents/MacOS/share/lua";
145+
else
146+
CONFIG="${HOME}/.config/vlc";
147+
LUA_USER="${HOME}/.local/share/vlc/lua";
148+
LUA_SYSTEM="$(python -c "import glob; print(
149+
glob.glob('/usr/lib/*/vlc/lua') +
150+
glob.glob('/usr/lib/vlc/lua'))[0]")";
151+
fi
152+
153+
############################################################################
154+
# TEST INSTALLATION LOCALLY
155+
############################################################################
156+
# Install with default parameters
157+
- dist/${TRAKT_HELPER_BIN} --debug install --yes --no-init-trakt-auth
158+
# Check that the helper has been installed
159+
- ls -ls "${LUA_USER}/trakt_helper"
160+
# And that the Lua interface is also installed
161+
- ls -ls "${LUA_USER}/intf/trakt.luac"
162+
# Run vlc to check that TraktForVLC is ready
163+
- vlc >/tmp/vlc.out 2>&1 & sleep 5; kill $!
164+
- sleep 5; cat /tmp/vlc.out
165+
# Check that it found the helper
166+
- |
167+
helper=$(cat /tmp/vlc.out | perl -ne '
168+
if ($_ =~ m/\[trakt\] lua interface: helper:/g) {
169+
$_ =~ s/^.*\[trakt\] lua interface: helper: //g;
170+
print;
171+
}')
172+
test "$helper" == "${LUA_USER}/trakt_helper"
173+
if [ $? -ne 0 ]; then
174+
echo "Helper is '${helper}' instead of '${LUA_USER}/trakt_helper'"
175+
cat /tmp/vlc.out
176+
false
177+
else
178+
echo "Helper '${helper}' was found"
179+
fi
180+
# And that it was requesting for Trakt.tv access
181+
- |
182+
test "$(cat /tmp/vlc.out |
183+
perl -ne 'print "OK" if $_ =~ m/^\s*TraktForVLC is not setup/'
184+
)" == "OK"
185+
if [ $? -ne 0 ]; then
186+
echo "TraktForVLC is NOT requesting for Trakt.tv access :("
187+
false
188+
else
189+
echo "TraktForVLC is requesting for Trakt.tv access :)"
190+
fi
191+
# And that it did not fail before we stopped
192+
- |
193+
test "$(cat /tmp/vlc.out |
194+
perl -ne 'print "NOK" if $_ =~ m/^\s*TraktForVLC setup failed/'
195+
)" != "NOK"
196+
if [ $? -ne 0 ]; then
197+
echo "TraktForVLC failed (setup fail) before we stopped VLC :("
198+
false
199+
else
200+
echo "TraktForVLC did not fail (setup fail) before we stopped VLC :)"
201+
fi
202+
# Test the update tool
203+
- |
204+
vlc --lua-config "trakt={check_update={file=\"$(pwd)/dist/${TRAKT_HELPER_BIN}\",wait=30,output=\"/tmp/update_output.log\"}}";
205+
ls "/tmp/update_output.log";
206+
cat "/tmp/update_output.log"
207+
# Then uninstall
208+
- "\"${LUA_USER}/trakt_helper\" --debug uninstall --yes"
209+
# And check that the files are not there
210+
- test \! -f "${LUA_USER}/trakt_helper"
211+
- test \! -f "${LUA_USER}/intf/trakt.luac"
212+
213+
############################################################################
214+
# IN BETWEEN CLEANING
215+
############################################################################
216+
- rm /tmp/vlc.out
217+
218+
############################################################################
219+
# TEST INSTALLATION SYSTEM-WIDE
220+
############################################################################
221+
# Install with default parameters
222+
- sudo dist/${TRAKT_HELPER_BIN} --debug install --yes --system --no-init-trakt-auth
223+
# Check that the helper has been installed
224+
- ls -ls "${LUA_SYSTEM}/trakt_helper"
225+
# And that the Lua interface is also installed
226+
- ls -ls "${LUA_SYSTEM}/intf/trakt.luac"
227+
# Run vlc to check that TraktForVLC is ready
228+
- vlc >/tmp/vlc.out 2>&1 & sleep 5; kill $!
229+
- sleep 5; cat /tmp/vlc.out
230+
# Check that it found the helper
231+
- |
232+
helper=$(cat /tmp/vlc.out | perl -ne '
233+
if ($_ =~ m/\[trakt\] lua interface: helper:/g) {
234+
$_ =~ s/^.*\[trakt\] lua interface: helper: //g;
235+
print;
236+
}')
237+
test "$helper" == "${LUA_SYSTEM}/trakt_helper"
238+
if [ $? -ne 0 ]; then
239+
echo "Helper is '${helper}' instead of '${LUA_SYSTEM}/trakt_helper'"
240+
false
241+
else
242+
echo "Helper '${helper}' was found"
243+
fi
244+
# And that it was requesting for Trakt.tv access
245+
- |
246+
test "$(cat /tmp/vlc.out |
247+
perl -ne 'print "OK" if $_ =~ m/^\s*TraktForVLC is not setup/'
248+
)" == "OK"
249+
if [ $? -ne 0 ]; then
250+
echo "TraktForVLC was NOT requesting for Trakt.tv access :("
251+
false
252+
else
253+
echo "TraktForVLC was requesting for Trakt.tv access :)"
254+
fi
255+
# And that it did not fail before we stopped
256+
- |
257+
test "$(cat /tmp/vlc.out |
258+
perl -ne 'print "NOK" if $_ =~ m/^\s*TraktForVLC setup failed/'
259+
)" != "NOK"
260+
if [ $? -ne 0 ]; then
261+
echo "TraktForVLC failed (setup fail) before we stopped VLC :("
262+
false
263+
else
264+
echo "TraktForVLC did not fail (setup fail) before we stopped VLC :)"
265+
fi
266+
# Then uninstall
267+
- "sudo \"${LUA_SYSTEM}/trakt_helper\" --debug uninstall --yes --system"
268+
# And check that the files are not there
269+
- test \! -f "${LUA_SYSTEM}/trakt_helper"
270+
- test \! -f "${LUA_SYSTEM}/intf/trakt.luac"
271+
272+
before_deploy:
273+
- |
274+
if [ -n "${TRAVIS_TAG}" ]; then
275+
RELEASE_DRAFT=false;
276+
if [ -z "${TRAKT_VERSION_PRE_TYPE}" ]; then
277+
RELEASE_PRE=false;
278+
else
279+
RELEASE_PRE=true;
280+
fi;
281+
else
282+
TRAKT_VERSION_NAME="${TRAVIS_BRANCH}-branch";
283+
RELEASE_DRAFT=true;
284+
RELEASE_PRE=false;
285+
TRAKT_VERSION_DESCRIPTION="Draft of release for branch ${TRAVIS_BRANCH}. ${TRAKT_VERSION_DESCRIPTION}";
286+
fi
287+
- |
288+
echo "RELEASE NAME: ${TRAKT_VERSION_NAME}"
289+
echo "RELEASE DESCRIPTION: ${TRAKT_VERSION_DESCRIPTION}"
290+
echo "IS PRE RELEASE ? ${RELEASE_PRE}"
291+
echo "IS RELEASE DRAFT ? ${RELEASE_DRAFT}"
292+
293+
deploy:
294+
# Need to duplicate the release as travis do not manage properly the
295+
# conversion of 'true' and 'false' strings to booleans
296+
- provider: releases
297+
name: ${TRAKT_VERSION_NAME}
298+
body: ${TRAKT_VERSION_DESCRIPTION}
299+
api_key: ${GITHUB_TOKEN}
300+
file: dist/${TRAKT_HELPER_BIN}
301+
draft: false
302+
prerelease: true
303+
skip_cleanup: true
304+
on:
305+
condition: '-n "${TRAKT_VERSION_PRE_TYPE}"'
306+
tags: true
307+
- provider: releases
308+
name: ${TRAKT_VERSION_NAME}
309+
body: ${TRAKT_VERSION_DESCRIPTION}
310+
api_key: ${GITHUB_TOKEN}
311+
file: dist/${TRAKT_HELPER_BIN}
312+
draft: false
313+
prerelease: false
314+
skip_cleanup: true
315+
on:
316+
condition: '-z "${TRAKT_VERSION_PRE_TYPE}"'
317+
tags: true
318+
319+
after_success:
320+
- if [ -z "${TRAVIS_TAG}" ] && [ "${TRAVIS_BRANCH}" == "master" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
321+
pipenv install scikit-ci-addons &&
322+
pipenv run ci_addons publish_github_release --prerelease-packages "dist/${TRAKT_HELPER_BIN}" --prerelease-packages-clear-pattern "TraktForVLC_*_${TRAVIS_OS_NAME}" --prerelease-packages-keep-pattern "${TRAKT_HELPER_BIN}" --prerelease-sha "${TRAVIS_BRANCH}" --re-upload "${TRAVIS_REPO_SLUG}";
323+
fi

Pipfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[[source]]
2+
3+
url = "https://pypi.python.org/simple"
4+
verify_ssl = true
5+
name = "pypi"
6+
7+
8+
[dev-packages]
9+
10+
pyinstaller = "*"
11+
12+
13+
[packages]
14+
15+
requests = "*"
16+
imdbpie = "*"
17+
tvdb-api = "*"
18+
fuzzywuzzy = "*"
19+
python-levenshtein = "*"
20+
pytz = "*"
21+
futures = "*"
22+
tmdbsimple = "*"

0 commit comments

Comments
 (0)