Commit Graph

51 Commits

Author SHA1 Message Date
Thomas 0efeb9ffdf Support videos when WebTorrent is disabled
The URL of the video is not stored in the same attribute of the response
if WebTorrent is enabled or not.
It caused a bug when trying to play a video which do not use WebTorrent.

Also create a "quality" job to run pylint automatically on merge
requests. The contributing guidelines are updated with this information
and the remaining pylint violations were fixed in the code.

See merge request StCyr/plugin.video.peertube!11 for more information
2021-04-11 21:51:35 +00:00
Thomas c723ced0c6 Fix the selection of instances
When a new instance was selected from the list of instances, it had no
effect because the new instance URL was saved in an attribute that was
reset at the next call of the add-on.
Now when the user selects a new instance, the associated setting is
updated so that this value can be reused the next time the add-on is
called or started.

Also took this opportunity to refactor the access to the add-on's
settings: there are now wrapper methods in kodi_utils.py which
encapsulates the call to Kodi APIs to make the code simpler.

See merge request StCyr/plugin.video.peertube!10 for more information
2021-04-11 08:44:18 +00:00
Thomas Bétous a86f2b8f09 Update the URL for libtorrent install
The short URL was pointing to the wrong wiki (the one in my fork)
2021-04-08 23:42:32 +02:00
Thomas 4346178db9 Guide the user when libtorrent cannot be imported
Libtorrent is required to play videos but its installation is still
manual so now a message is displayed when libtorrent could not be
imported instead of having a "service could not start" error at Kodi
startup.
The message contains a link to a page which explains how to install
libtorrent. It will be displayed when:
* the add-on starts
* the user selects a video to play (including when called externally)

Other additions:
* Create a kodi_utils module to centralize some calls to the Kodi API
* Add license information in the header of the files
* Ignore some files in Git (python cache and Mac OS system file)
2021-04-08 23:25:49 +02:00
Thomas 7a21bd92ac Allow playing videos only with the video ID
Now the "play_video" action can be called with the ID of the video (and
optionally the URL of the instance hosting the video) as parameter
instead of the full URL: it will allow other add-ons to call the add-on
to play videos since the full URL contains the resolution which is not
known.

It led to some refactoring and changes in the code:
* Only the instance and the id of a video is retrieved when browsing and
  listing videos which improves the performance a lot (the video URL and
  the resolution are defined only when the video is played)
* the "https://" prefix is now automatically added to the instances URL
  because the instance-related REST APIs use URLs without this prefix.
  It also simplifies the external API because the user does not have to
  provide this prefix.
  Consequently the prefix was removed from the default value of the
  selected instance in the settings: it simplifies the code but it
  generates a non-backward compatible change. The impact is limited
  because it can be easily fixed by resetting the settings to the
  default value and there are very few users currently.

Other changes:
 - manage errors when retrieving the information of a video
 - fix some PEP 8 errors
2021-04-08 23:16:39 +02:00
Thomas d657480eab Browse only local videos by default
Use "local" instead of "all-local" by default because "all-local"
requires admin privileges

Other improvements:
* Replace urllib with requests to make the management of the HTTP
  requests simpler (better error handling and easier implementation of
  complex requests in the future)
* Refactor the functions used to build the HTTP request to improve
  maintainability (don't know if it makes sense to keep a single
  function for the "search" and the "list videos" request).
* Use "urlencode" to generate the Kodi URL using a dict to make it more
  generic.
* Create a function to log messages easily in Kodi's debug log. It will
  decrease the amount of duplicate code.
* Fix some errors reported by pylint with regards to PEP 8
2021-03-28 21:27:28 +00:00
philippe lhardy 913e5fb905 add a video_filter parameter to be able to browse only local
- when browsing ( and not searching ) it is possible to select
filter=local that will show only local video
- create dedicated method to build kodi and peertube api url
- bumped version to 0.3.1.1 to indicate this change
  - if selected upstream might want to change it to 0.3.2
2018-11-24 17:31:09 +01:00
Cyrille Bollu 3dd68c8ee2 Implemented the 'preferred video resolution' functionality:
Addon will use, by order of preferrence:
  1) The video matching exactly the user's preferrence
  2) A video with the best resolution that is lower than the user's preferrence
  3) The video with the lowest resolution that is higher than the user's preferrence
2018-08-02 17:36:58 +02:00
Cyrille Bollu 8b80a1fad7 Added a setting for 'preferred video resolution'
Functionality not yet implemented though
2018-08-02 16:58:07 +02:00
Famille Bollu 17352c6313 Added a test to make sure a 'search videos' request actually returned results 2018-07-31 22:36:48 +02:00
Famille Bollu e7bbc94b35 Must add the 'https://' scheme before data['host'] in select_instance 2018-07-31 22:09:32 +02:00
Famille Bollu 38bb4414c4 Fixed a but in main menu where menu entries were not called with the 'isFolder'
attribute set to True
2018-07-31 22:00:33 +02:00
Famille Bollu 3c3b04c528 This was not such a bright idea to name a variable 'item' 2018-07-31 21:46:16 +02:00
Cyrille Bollu 054c446354 Bumped to version 0.3.0 2018-07-31 16:52:45 +02:00
Cyrille Bollu a3dc2511a5 Implemented the 'Browse instances" functionality
Major refactoring
2018-07-31 16:50:22 +02:00
Cyrille Bollu 46c7c8776f Implemented basic user-configurable videos sort method
Currently allows sorting by views or likes numbers
2018-07-31 15:26:27 +02:00
Cyrille Bollu 0750029db7 Added a timeout of 10 seconds to download the torrent's metadata. 2018-07-31 15:16:24 +02:00
Cyrille Bollu 267e15cc0f Do not sort addon's main menu 2018-07-31 15:08:46 +02:00
Cyrille Bollu e9f81c8370 Made the items_per_page user setting configurable. 2018-07-31 12:23:16 +02:00
Cyrille Bollu 382de6d954 FIxed the test used to decide whether to display a 'Next' button or not. 2018-07-31 10:43:17 +02:00
Cyrille Bollu d41c770f41 Removed the "Previous" button as the ".." link already does the same
(It's how the youtube-dl addon does it actualy)
2018-07-31 10:36:55 +02:00
Famille Bollu 0ad354fb0d Fixed some bugs due to latest commit 2018-07-30 21:24:41 +02:00
Famille Bollu d648fd7728 Prepared for the 'select other instance' functionality 2018-07-30 21:17:08 +02:00
Famille Bollu 4ab6cef360 Added basic error handling around ithe two calls to urllib2.urlopen 2018-07-30 20:42:03 +02:00
Famille Bollu 3debccfea7 Fixed some bugs. "Search" functionality still doesn't work though 2018-07-30 12:33:37 +02:00
Famille Bollu ac976ab8cf Implemented 'search video on selected instance' functionality 2018-07-30 12:00:27 +02:00
Famille Bollu 0f11b12350 Corrected a bug where I used the 'start' parameter as an int when it was a str 2018-07-30 11:28:27 +02:00
Famille Bollu 4916d6a757 Do not sort videos alphabeticaly 2018-07-30 11:19:58 +02:00
Famille Bollu ffead3ee69 Implemented navigation in 'browse selected instance' menu 2018-07-29 22:15:06 +02:00
Famille Bollu 4b9e5a26b4 Started implementing the items_per_page functionality 2018-07-28 13:54:19 +02:00
Famille Bollu 9351feff80 Added an items_per_page setting to allow user to specify the number of videos
she wants to display per page.
Functionality not implemented yet though.
2018-07-28 13:44:57 +02:00
Famille Bollu 8f1749b8ef Added a main menu + started implementing paginated video list 2018-07-28 13:35:28 +02:00
Famille Bollu 2d02a5c8ed Had forgot a 'self' as argument of the play_video_continue function.
Addon seems to work now
2018-07-27 18:40:24 +02:00
Cyrille Bollu 4c47e8e382 Limit the number of results from the GET /videos API call. 2018-07-27 15:05:09 +02:00
Cyrille Bollu fe91fa4e90 Added the 'preferred_instance" setting to allow the user to specify a
preferred peerinstance to connect to (defaults to 'https://framatube.org')
2018-07-27 14:43:21 +02:00
Cyrille Bollu 143e066fbc Changed logging level to LOGDEBUG as requested by https://kodi.wiki/view/Add-on_rules 2018-07-27 11:26:40 +02:00
Cyrille Bollu fbd6a0599e Fixed file permission 2018-07-27 11:24:08 +02:00
Cyrille Bollu 3cbf940e82 Updated code to use torrent files rather than magnets (For some reason magnet files
provided by peerTube don't work) + refactored code related to the management of the
addon's temporary directory
2018-07-27 10:55:50 +02:00
Famille Bollu 914bcb9234 Added logging 2018-07-27 07:40:45 +02:00
Famille Bollu dcddedf299 in classes, callback functions should be specified self.callbackfunction and not just
callbackfunction (this time in the peertubeAddon class)
2018-07-26 21:59:50 +02:00
Famille Bollu d38abc0bf6 Fixed a typo and an error in PeertubeDownloader's init function 2018-07-26 21:59:05 +02:00
Famille Bollu db7984431b write() can only use buffers of type strings or bytearrays, not buffers of unicode type 2018-07-26 21:54:59 +02:00
Famille Bollu 37f1b91d54 Fixed an indentation issue in peertube.py + fixed an error when parsing the json result
of the call to api/v1/videos
2018-07-26 21:44:13 +02:00
Famille Bollu 9b79c9dfa1 Cleaned import stanzas 2018-07-26 20:03:32 +02:00
Famille Bollu 1f1132f4fc Refactored code to let the downloader thread be started by the service 2018-07-26 19:59:47 +02:00
Cyrille Bollu 71e76f38cc Refactored code to use a downloader thread to download torrent in the background.
I haven't tested it yet.
2018-07-26 17:53:27 +02:00
Cyrille Bollu 7cfc9b8c23 The code to retrieve the torrent's url was not correct anymore with the
modifications made in the last few commits.
2018-07-26 14:22:22 +02:00
Cyrille Bollu c825daef58 Added thumbnail info to ListItem's 2018-07-26 13:17:47 +02:00
Cyrille Bollu 4271e7baa4 Added code to get all videos from a peertube instance + added
some code to enrich the ListItem's with more info

TODO: Make it possible to specify the instance the user wants to browse
2018-07-26 13:12:27 +02:00
Cyrille Bollu 83a37cbcd3 file peertube.py isn't supposed to be run from the command-line 2018-07-26 11:52:35 +02:00