Code Monkey home page Code Monkey logo

napi-py's People

Contributors

emkor avatar lipowskm avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

napi-py's Issues

(Possibly) redundant usage of 7z

So one thing I noticed is that you could get rid of the necessity of having 7z as an external tool completely.

You can manage it using py7zlib package. Here's a sample code how I'm using it:

from io import BytesIO
import base64
import xml.etree.ElementTree as ET
from py7zlib import Archive7z

response = requests.post(
    url='http://www.napiprojekt.pl/api/api-napiprojekt3.php',
    data=dict(
        downloaded_subtitles_id=movie_hash,
        downloaded_subtitles_lang='PL',
        client='NapiProjekt',
        mode=17,
    )
)
parser = ET.XML(response.content)
content = parser.find('subtitles').find('content').text
decoded_content = base64.b64decode(content)
buffer = BytesIO(decoded_content)
archive = Archive7z(buffer, password='iBlm8NTigvru0Jr0')
encoded_subtitles = archive.getmember(0).read()
subtitles = encoded_subtitles.decode('Windows-1250 or some other encoding')

Don't ask me about the password since I don't know where it came from, I found this piece of code somewhere on Github and did a little refactor, since it was outdated. But it does it's job obviously and doesn't require 7z at all.

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.