manga_scrappy's Issues
Create Docker Compose config
- Have three services:
- web (running the dockerfile created before)
- database (running a postgres database)
- redis (running a redis server)
- Make sure "database" and "redis" servers are accessible from the "web" container
- Build the services using docker compose
- Run the services using docker compose
Install and integrate celery
- Install celery package
- Configure it to use the redis service as a broker
- Integrate it with django
- Create a tasks.py file in one of the existing django apps
- Implement a function in tasks.py that is a celery task (for example a function that waits for X seconds and returns a string with the current datetime, X is parameter)
- Import implemented function in views.py and execute a celery task based on some user action (for the function above, the user inputs the number of seconds and get the id of the celery task that is created)
- Based on the task id, the user can then retrieve the result if the task (another endpoint that receives the task id as the parameter)
Setup Django Project
- Create a repo containing a simple Django project
- Install Django in a virtualenv
- Create a new project and a "hello" app with manage.py
- Implement a view at the root of the "hello" app returning the "Hello World!" message
- Make sure accessing "localhost:8000/hello" will return a blank page with the "Hello World!" message
Create a model
- Create a new Django app called sample_data
- Create a simple table
- Use makemigrations & migrate to reflect the changes in the database
- Make sure that every time the project is started all the migrations are applied
- Implement a management command called "populate_sample_data" that populates the database with some sample data
- Implement an endpoint that returns in a json all the information in the table
Integrate graphql in the project
- Add graphql to installation requirements
- Configure graphql to the project and access graphiql
- Create a query that retrieves all data about manga that we have in the system
- Create a mutation that will allow the user to add some tags to any manga chapter. Then create a query that will retrieve all mangas for a list of tags provided by the user as input
- Replace all endpoints with graphql queries and mutations.
Implement project functionality
- Create a new Django app representing the main app of the project.
- Create a model representing a manga to capture metadata. At a minimum it would need: url, name, years. You can add anything else you will need as you implement the code.
- Create a view that receives an url from the user as a query parameter (we don't need a form here, we'll just query the url for the view with ?url= to send the url)
- The view will return a json to the user containing the field "message" in case of success or "error" in case of error.
If the url is received successully, a celery task is started and the task id is returned to the user as a response message. If there's a problem with the url, the user will receive the error in the response json.
Make sure to set status codes for the reponse (200 or 400). - Implement a celery task that scrapes the page at the url submitted by the user. Save metadata about the submitted manga and save images (it probably makes sense to have another model for the images).
If during the implementation subparts of manga can be extracted (like chapters or episodes) I think it makes sense to have a model for these as well.
I think the final model will have the tables: - manga
- chapters (that will have foreign keys to manga)
- images (that will have foreign keys to chapters)
After metadata and images are successfully saved, trigger another celery task that will create the manga files (described as next objective). Save the manga file in the manga chapter model. - Implement another celery task that will create a manga file for a chapter after all the images have been downloaded for that chapter.
The file format for a comic book file is .cbz and I think we can use this tool to convert a folder of images to .cbz: https://pypi.org/project/ftcbz/
Then we can convert the .cbz file to an ebook format like .epub using this tool: https://pypi.org/project/reCBZ/
You'll have to decide if it's worth the effort to try to import these in python or if you rather used them as command line tools. - Create another endpoint (view) where the user can send a task id as query parameter and they will receive the status of the task. If the status is completed, the user will also receive metadata about the downloaded manga.
- Create an endpoint where the user can interact with all mangas in the system like so:
- on the root of the endpoint the user will receive data about all mangas in the system
- if the user specifies a manga id as a url parameter (no query parameter), they will receive the data for that specific manga or an error if the id does not exist
- if the users sends a ?search query parameter, return data about all the mangas matching the search (you can search whatever you want; at a minimum the search will happen on the name of the manga case insensitive)
- IF the users sends an url for a manga that's already in the system, don't create a task for it but just return the metadata to the user.
- Implement a django management command that will list all of the mangas in the system as detailed as possible. We should be able to see what task created a specific manga, what was the date when it was created, the name, chapters with number and names.
Create Docker image
- Install docker and make sure it works
- Create a "Dockerfile" file in the project root
- Implement the "Dockerfile" based on these objectives:
- Container uses latest version of python
- Project code is copied in the "/code" folder on the container storage
- Project requirements are installed based on requirements.txt file
- Starting the container runs the projects
- Project port is exposed outside the container
- Build the docker image based on "Dockerfile"
- Run the docker image and make sure that accessing "localhost:8000/hello" will return a blank page with the "Hello World!" message
- Open a bash shell in the running container and change something
- Use docker volumes to make code changes on the machine reflect in the container as well
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.