📜 ⬆️ ⬇️

Mixing Twitter + Movie we get TwiMov

I would like to tell you in this small text about how the idea was born, how the code was born and what we have at the moment on my TwiMov project.

Since childhood I have loved cinema, this fabulous and fantastic world, where there are so many completely unreal things. The world is not limited by anything, only the fantasy of the author. The world that makes empathize, empathize, understand. Cinema is not real life, it is virtual reality.

Since sometimes I just want to say something about the movie that I watched, for example, some graphomanism attacks me, I can't hold it in myself and I have to pour it on the keyboard, this is like a reminder for myself for the future and again the opportunity to analyze the film, I sit down at the computer and write a review. Successful, it will turn out or not very much I do not know and a little exciting, the rule of 80/20 is always in mind. But good, clear reviews with a lot of thoughts, ideas and analysis are the lot of professional authors and journalists, to my delight or regret I am not one of them. Therefore, at some point one of the topics on our Ufa rock forum, I realized that people are not always ready to write major reviews, but they willingly insert their “five kopecks”. Well, good, I try to follow all sorts of trends in the network, although from the first time I didn’t understand what Twitter was for me, then this time it was accurate to my tasks!
')
Idea.
I saw the idea immediately, transparently and easily.
There is for example a certain site on it brief notes are published from different users on different films. Notes are grouped by movie title. Short and concise as a sparrow feathers. Since I wanted to tie everything to independent customers, queues and delivery, I immediately chose Twitter, the day of reading the API documentation allowed me to say that all this is possible without any problems.
A certain bot @twimov was registered, which is still silent, but soon will also start talking :) Also a number of domains, among which the main one is www.TwiMov.ru . And the work began to boil.

twimov
Coding.
The task of the code was divided into 3 components:
1. A bot that picks up Twitter for a certain amount of time, checks and processes messages
2. Frontend, the withdrawal of reviews, films, information about users
3. Administration and control

1. Bot . It would seem clear and logical. But why did I decide to do it in Perl, I still do not understand, I took LWP, DBI :: MYSQL, IMAGE :: MAGICK and went to do ... But somehow everything is tight and tight, the authorization falls off on LWP, set modules specifically for Twitter had no desire, since I already imagined how much code it is in PHP, for example. Strange, but this task for me was poured into full care in PHP.
No sooner said than done. For the day, the code was rewritten into “pure” PHP, then everything was its own, well, except PDO, maybe. A convenient class for requests to Twitter has been written, it works through the standard file request functions, if allow_url_open is enabled, if not enabled via CURL.
The class for parsing the Twitter tape was written, the fact that immediately there was a hint of the universality of the class helped me quickly create a second object that also parses the private message feed for reviews.
BOT as such is the heart and core of the filling, it developed with all the ideas that I considered acceptable in our case, for example:
- Caching avatar users to at some point not to lose them and the connection with Twitter.
- search for a movie cover using Google and also caching it on your server with a size correction (thanks for that PHPThumb )
- search also in google movie trailer
All these items were completed as a whole by 5, cyclically and not all at once, but in the process, but I was satisfied and even now there are still ideas on how and how to help myself with automation.

2. Front end . The conclusion was the simplest. I did not drag along any old baggage of libraries or modules. I took a clean CodeIgniter framework (sorry, I’m already sorry to write on the “noodles”), expanded it alongside my classes to the Model, to the Front controller and Administrative controller, to make it more convenient and easier.
I didn’t even draw a design layout, just took my favorite darkly-gothic-emo colors and sketched in css, then how about I want to see the site. The design is still left for later, since the MVC architecture will allow me to change it instantly on the entire site. There are a number of "chips" and my personal rules about extending and writing code for CodeIgniter, which I took for myself from Ruby on Rails, in general, it’s like naming tables, functions, model extension, autoloading and initialization. If it is interesting to someone willing to share and describe them in the next article, I'm not greedy, maybe someone will come in handy.

3. Administration . Everything is again based on CodeIgniter, little authorization:
entrance

Well, here, too, without any particular embellishment, the UI designer is none of me, because I always do as convenient for my beloved and how quickly I will manage the content myself, as the only administrator of the site so far. But already a number of chips for myself outlined.

Immediately determined what and how I want to administer.

These are reviews separately of all users, with a list by page and in the future there will be an internal search.
list of reviews

review editor

This is the management of films, next to each film we observe its information and the state of fullness of the cover, video clip, text description with the help of icons.
movie list

And a movie editor. On it, I would like to stop a bit.
Technically, everything is simple, a bot can sometimes be mistaken, as Google is not uncommon, because the Administrator should have the opportunity to correct the name of the tape, just “perezalit” new movie cover and maybe choose a new video file for the trailer tape. Of course, there is an opportunity to independently indicate the address of the image and video, but basically I try for a number of keywords, again to ask Google about their presence, again if anyone is interested in how to work with Google search, ask, put a note on the new material. And then the man’s work, looked, chose, indicated. By the way, it is indicated via AJAX in order not to overload such large data arrays. In order not to write my wrapper around this whole thing, I routinely took JQuery, it’s not unusual to work with it after Prototype, but the wealth of plugins and extensions still forced me to switch to this JS library. The server gives the answers as usual in JSON, it's more convenient for me.
movie editor

And, of course, the list of users is also listed in the future with a search.
a list of users
At the moment, in order not to intrude into the privacy of users it is impossible to edit them, they always remain with their avatars on the site, but there is a possibility to BAN, perhaps for so many harsh measures can be useful in the fight against spammers and fluderastami.

Well, in general, that's all, and now just join www.twitter.com/twimov and write to him in this format

@twimov + !

PS Thanks for the invite and I hope the moderators will transfer to the Startup blog.
PPS Thanks for the karma, transferred to "I am promoting"

Source: https://habr.com/ru/post/80836/


All Articles