Git Product home page Git Product logo

pychomikbox's Introduction

pyChomikBox

Python 2.7 and 3.5 (and wasn't tested at lower versions) library for Chomikuj.pl file sharing service. It uses official app's (ChomikBox) protocol to comunicate with Chomikuj servers.

Installation

Just use pip, as you would with all python packages

$ pip install pyChomikBox

Examples

A simple example of usage

>>> from ChomikBox import Chomik
>>> c = Chomik('username', 'password')
>>> c.login()
>>> c
<ChomikBox.Chomik: username>
>>> print(c.list())
[<ChomikBox.ChomikFolder: "/prywatne/" (username)>, <ChomikBox.ChomikFolder: "/zachomikowane/" (username)>]

This code is logging at Chomikuj as username with password password and printing all files and folders of root folder.

You can find more examples in examples directory.

pychomikbox's People

Contributors

juniorjpdj avatar lopezloo avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pychomikbox's Issues

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Preset caused unexpected error (config:recommended)

Upload pause issue

I recive this error uploading small files, big files are ok.
Windows, python 3.7.5
Credentials are ok, I just hide some sensitive informations. As I just said, I can upload big files.

[00:16:35][DEBUG]: urllib3.connectionpool | Starting new HTTPS connection (1): box.chomikuj.pl:443
[00:16:35][DEBUG]: urllib3.connectionpool | https://box.chomikuj.pl:443 "POST /services/ChomikBoxService.svc HTTP/1.1" 200 391
[00:16:35][DEBUG]: ChomikBox.Chomik.username | Action sent: "Auth"
[00:16:35][DEBUG]: ChomikBox.Chomik.username | Logged in with token <hidden>
[00:16:35][DEBUG]: urllib3.connectionpool | Starting new HTTPS connection (1): chomikuj.pl:443
[00:16:35][DEBUG]: urllib3.connectionpool | https://chomikuj.pl:443 "GET /chomik/chomikbox/LoginFromBox?t=<hidden>&returnUrl=username HTTP/1.1" 302 122
[00:16:36][DEBUG]: urllib3.connectionpool | https://chomikuj.pl:443 "GET /username HTTP/1.1" 200 16916
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Loading folders from folder 0
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Sending action: "Folders"
[00:16:36][DEBUG]: urllib3.connectionpool | https://box.chomikuj.pl:443 "POST /services/ChomikBoxService.svc HTTP/1.1" 200 None
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Action sent: "Folders"
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Getting file upload data for file "README.rst" in folder 461
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Sending action: "UploadToken"
[00:16:36][DEBUG]: urllib3.connectionpool | https://box.chomikuj.pl:443 "POST /services/ChomikBoxService.svc HTTP/1.1" 200 412
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Action sent: "UploadToken"
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Started uploading file "README.rst" to folder 461
[00:16:36][DEBUG]: urllib3.connectionpool | Starting new HTTP connection (1): s6963.chomikuj.pl:8084
869
[00:16:36][DEBUG]: ChomikBox.Chomik.username | Upload of file "README.rst" paused
[00:16:37][DEBUG]: urllib3.connectionpool | Starting new HTTP connection (2): s6963.chomikuj.pl:8084
[00:16:37][DEBUG]: urllib3.connectionpool | http://s6963.chomikuj.pl:8084 "GET /resume/check/?key=<hidden> HTTP/1.1" 200 57
Traceback (most recent call last):
  File "example.py", line 70, in <module>
    uploader.resume()
  File "C:\Users\kamil\Desktop\pyChomikBox-master\ChomikBox\ChomikBox.py", line 696, in resume
    resume_from = int(resp['@file_size'])
KeyError: '@file_size'

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

None detected

SeekableHTTPFile seek() is not working

I've code:

from ChomikBox.ChomikBox import Chomik

C = Chomik('...', '...')
C.login()
F = C.list()[0].list()[0].list()[2].open()

print("F: ", type(F))
F.seek(offset=0)

but it fails with error:

F:  <class 'ChomikBox.utils.SeekableHTTPFile.SeekableHTTPFile'>
Traceback (most recent call last):
  File "/dev/shm/pyChomikBox/test.py", line 8, in <module>
    F.seek(offset=0)
  File "/dev/shm/pyChomikBox/ChomikBox/utils/SeekableHTTPFile.py", line 62, in seek
    self._r.close()
AttributeError: 'NoneType' object has no attribute 'close'

It's seems that self._r in SeekableHTTPFile's seek() method is not properly assigned before use.

KeyError: 'AddFolderResponse' - (·) U+00B7 char problem

When folder name contains (·) U+00B7 char, folder is not created on Chomikuj:

Folder test name: TEST·TEST

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyChomikBox-0.2.1-py3.8.egg/ChomikBox/ChomikBox.py", line 209, in new_folder
  File "/usr/local/lib/python3.8/dist-packages/pyChomikBox-0.2.1-py3.8.egg/ChomikBox/ChomikBox.py", line 428, in new_folder
  File "/usr/local/lib/python3.8/dist-packages/pyChomikBox-0.2.1-py3.8.egg/ChomikBox/ChomikBox.py", line 270, in _send_action
KeyError: 'AddFolderResponse'

Files listing fails sometimes

Currently to get list of files you need:

  1. Log into chomikbox and web.
  2. Call chomikuj.pl/actions/chomikbox/DownloadFolderChomikBox and grab chomikbox url:
    chomik://files/:chomik_id/folder_id
    (chomik_id is not same account ID as we get after chomikbox login)
  3. Call SOAP API like before.

The problem is, to obtain this URL you need to be logged in ChomikBox. If you aren't logged, you get HTML response "download ChomikBox blahblah". And you are considered as logged after calling CheckEvents SOAP action (our ping() method)... which fails sometimes. I was even handling exception to just ignore this because I though this error occurs if we spam with this event a bit. But no. You can do it on fresh and it just fail. You try few times more and it won't fail if you are lucky enough.

Examples does not work, probably some protocol changes

When trying to test a list.py i always get:

Traceback (most recent call last):
  File "./list.py", line 31, in <module>
    files.extend(f.files_list(only_downloadable=True))
  File "/usr/lib/python3.7/site-packages/ChomikBox/ChomikBox.py", line 352, in files_list
    resp = self._send_action('Download', a_data)
  File "/usr/lib/python3.7/site-packages/ChomikBox/ChomikBox.py", line 275, in _send_action
    raise SendActionFailedException(action, resp['a:errorMessage'])
ChomikBox.ChomikBox.SendActionFailedException: Download: failed : requested file(s) not available

When trying example.py:

[21:18:46][DEBUG]: ChomikBox.Chomik.USERNAME | Sending action: "Auth"
[21:18:46][DEBUG]: urllib3.connectionpool | Starting new HTTPS connection (1): box.chomikuj.pl:443
[21:18:47][DEBUG]: urllib3.connectionpool | https://box.chomikuj.pl:443 "POST /services/ChomikBoxService.svc HTTP/1.1" 200 279
[21:18:47][DEBUG]: ChomikBox.Chomik.USERNAME | Action sent: "Auth"
[21:18:47][DEBUG]: ChomikBox.Chomik.USERNAME| Logged in with token d3afa824-b61e-4de5-b31e-c26f2b87d6a7
[21:18:47][DEBUG]: urllib3.connectionpool | Starting new HTTPS connection (1): chomikuj.pl:443
[21:18:47][DEBUG]: urllib3.connectionpool | https://chomikuj.pl:443 "GET /chomik/chomikbox/LoginFromBox?t=d3afa824-b61e-4de5-b31e-c26f2b87d6a7&returnUrl=USERNAME HTTP/1.1" 302 126
[21:18:48][DEBUG]: urllib3.connectionpool | https://chomikuj.pl:443 "GET /USERNAME HTTP/1.1" 200 13917
[21:18:48][DEBUG]: ChomikBox.Chomik.USERNAME | Loading folders from folder 0
[21:18:48][DEBUG]: ChomikBox.Chomik.USERNAME | Sending action: "Folders"
[21:18:48][DEBUG]: urllib3.connectionpool | https://box.chomikuj.pl:443 "POST /services/ChomikBoxService.svc HTTP/1.1" 200 685
[21:18:48][DEBUG]: ChomikBox.Chomik.USERNAME | Action sent: "Folders"
[21:18:48][DEBUG]: ChomikBox.Chomik.USERNAME | Loading files from folder 0
[21:18:48][DEBUG]: ChomikBox.Chomik.USERNAME | Sending action: "Download"
[21:18:48][DEBUG]: urllib3.connectionpool | https://box.chomikuj.pl:443 "POST /services/ChomikBoxService.svc HTTP/1.1" 200 286
Traceback (most recent call last):
  File "./myChomikuj.py", line 32, in <module>
    fold = c.get('upload')
  File "/usr/lib/python3.7/site-packages/ChomikBox/ChomikBox.py", line 201, in get
    found = self.get_file(name, case_sensitive)
  File "/usr/lib/python3.7/site-packages/ChomikBox/ChomikBox.py", line 188, in get_file
    for f in self.files_list():
  File "/usr/lib/python3.7/site-packages/ChomikBox/ChomikBox.py", line 352, in files_list
    resp = self._send_action('Download', a_data)
  File "/usr/lib/python3.7/site-packages/ChomikBox/ChomikBox.py", line 275, in _send_action
    raise SendActionFailedException(action, resp['a:errorMessage'])
ChomikBox.ChomikBox.SendActionFailedException: Download: failed : requested file(s) not available

Of course i provided valid credentials and this seems to work. Tested on Python 3.7.0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.