{"id":253021,"date":"2015-03-13T15:13:02","date_gmt":"2015-03-13T11:13:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=253021"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=253021","title":{"rendered":"\u0422\u0443\u0442\u043e\u0440\u0438\u0430\u043b \u043f\u043e Coub API"},"content":{"rendered":"<p>     \t\u041d\u0430 \u0434\u043d\u044f\u0445 \u043c\u044b \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b\u0438 <a href=\"http:\/\/coub.com\/dev\/docs\/Coub+API\/Overview\">Coub API<\/a>. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043b\u0435\u043d\u0442\u0443, \u043b\u0430\u0439\u043a\u0430\u0442\u044c, \u0440\u0435\u043a\u043e\u0431\u0438\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435, \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 API. \u041d\u043e \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435\u200a\u2014\u200a\u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0437 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 API \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u0431\u044b.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u043a\u043e\u0431\u0430 \u043d\u0430 Ruby on Rails. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0431 \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0431 \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c:<\/p>\n<p>  <iframe loading=\"lazy\" src=\"\/\/coub.com\/embed\/5eoxr?muted=false&#038;autostart=false&#038;originalSize=false&#038;hideTopBar=false&#038;startWithHD=false\" width=\"640\" height=\"360\" frameborder=\"0\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>  \u0420\u0430\u0431\u043e\u0447\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043b\u0435\u0436\u0438\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/fantozzi.dev2.workisfun.ru\">fantozzi.dev2.workisfun.ru<\/a>, \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0413\u0438\u0442\u0445\u0430\u0431\u0435: <a href=\"https:\/\/github.com\/igorgladkoborodov\/memegenerator\">github.com\/igorgladkoborodov\/memegenerator<\/a><br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>OAuth<\/h2>\n<p>  \u041a\u043e\u0431 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 <a href=\"http:\/\/oauth.net\/\">OAuth 2.0<\/a>. \u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 API (\u0424\u0435\u0439\u0441\u0431\u0443\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440), \u043f\u043e \u043d\u0435\u043c\u0443 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u044b.<\/p>\n<p>  \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a: \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e \u0441\u0432\u043e\u0438\u043c \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043d\u0430 coub.com, \u0442\u0430\u043c \u041a\u043e\u0431 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442, \u0441\u043e\u0433\u043b\u0430\u0441\u0435\u043d \u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e \u0434\u043e\u0441\u0442\u0443\u043f. \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442, \u0442\u043e \u041a\u043e\u0431 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0438 \u043e\u0442\u0434\u0430\u0435\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c \u0442\u043e\u043a\u0435\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0442\u043e\u043c \u0443\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u0441\u0435\u0445 API-\u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u0424\u0435\u0439\u0441\u0431\u0443\u043a \u0438\u043b\u0438 \u0422\u0432\u0438\u0442\u0442\u0435\u0440.<\/p>\n<p>  \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430 RoR \u0438 \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 OAuth \u0434\u043b\u044f \u0440\u0435\u043b\u044c\u0441\u043e\u0432 \u0432\u0441\u0435 \u0443\u0436\u0435 \u0434\u0430\u0432\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0433\u0435\u043c <a href=\"https:\/\/github.com\/intridea\/omniauth-oauth2\">omniauth-oauth2<\/a> \u0438 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0431\u043e\u0432\u0441\u043a\u0438\u0439 \u0433\u0435\u043c <a href=\"https:\/\/github.com\/coub\/omniauth-coub\">omniauth-coub<\/a>.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f<\/h2>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441 \u043a\u0440\u0430\u0441\u043d\u043e\u0440\u0435\u0447\u0438\u0432\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c memegenerator \u0438 \u043f\u0440\u0438\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u043a Pow (\u0438\u043b\u0438 \u043a\u0442\u043e \u0447\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f):<\/p>\n<pre><code class=\"bash\">$ cd ~\/apps\/ $ rails new memegenerator $ ln -s ~\/apps\/memegenerator\/ ~\/.pow\/memegenerator <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/memegenerator.dev\">memegenerator.dev<\/a> \u0436\u0438\u0432\u0435\u0442 \u043f\u0443\u0441\u0442\u043e\u0435 \u0440\u0435\u043b\u044c\u0441\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<p>  2. \u0420\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0435 \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/coub.com\/dev\/applications\/\">coub.com\/dev\/applications\/<\/a><\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/5b5\/cb1\/a52\/5b5cb1a524184024a18acccea31d379e.png\"\/><\/p>\n<p>  \u0412 \u043f\u043e\u043b\u0435 Website \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0443\u0440\u043b \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0432 \u043f\u043e\u043b\u0435 Callback URL \u043f\u0438\u0448\u0435\u043c <\/p>\n<pre>http:\/\/memegenerator.dev\/auth\/coub\/callback<\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u041a\u043e\u0431 \u0434\u0430\u0441\u0442 \u043d\u0430\u043c Application ID \u0438 Secret, \u043e\u043d\u0438 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/bf9\/e18\/da7\/bf9e18da71834e42b209a621846e41ea.png\"\/><\/p>\n<p>  3. \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0433\u0435\u043c omniauth-coub:<\/p>\n<p>  Gemfile:  <\/p>\n<pre><code class=\"ruby\">gem &quot;omniauth-coub&quot; <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">$ bundle install <\/code><\/pre>\n<p>  4. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u0431 \u0432 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b omniauth:<\/p>\n<p>  config\/initializers\/omniauth.rb:  <\/p>\n<pre><code class=\"ruby\">Rails.application.config.middleware.use OmniAuth::Builder do   provider :coub, ENV[&quot;COUB_KEY&quot;], ENV[&quot;COUB_SECRET&quot;], scope: &quot;logged_in,create&quot; end <\/code><\/pre>\n<p>  COUB_KEY \u0438 COUB_SECRET\u200a\u2014\u200a\u044d\u0442\u043e Application ID \u0438 Secret \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0433\u043e \u0448\u0430\u0433\u0430, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0432 ENV \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0438\u043b\u0438 \u043f\u043e\u043a\u0430 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u0440\u044f\u043c\u043e \u0442\u0443\u0442, \u0445\u043e\u0442\u044f \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043a\u043e\u0434\u0435 \u043a\u043b\u044e\u0447\u0438 \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0443 \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 Pow, \u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0432 \u0444\u0430\u0439\u043b\u0435 .powenv \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f:<\/p>\n<p>  .powenv:  <\/p>\n<pre><code class=\"bash\">export COUB_KEY=&quot;[Application ID]&quot; export COUB_SECRET=&quot;[Secret]&quot; <\/code><\/pre>\n<p>  \u0412 scope \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a\u0438\u043c\u0438 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u043b\u0430\u0434\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435. \u041d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u043e\u0431\u043e\u0432, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0438\u0448\u043d\u0435\u0433\u043e \u043c\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0441\u0438\u0442\u044c, \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044e \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u0431\u0430: logged_in, create. \u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0440\u0435\u0436\u0438\u043c\u043e\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 <a href=\"http:\/\/coub.com\/dev\/docs\/Coub+API\/Authentication\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u043a API<\/a>.<\/p>\n<p>  5. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043c\u0435\u0442\u043e\u0434\u043e\u043c from_omniauth, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0438\u043b\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 \u0431\u0430\u0437\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u043d\u0430\u043c \u0441\u0435\u0440\u0432\u0435\u0440 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 \u041a\u043e\u0431\u0435.<\/p>\n<p>  \u0427\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u044d\u0442\u043e\u043c \u043f\u0443\u043d\u043a\u0442\u0435 \u0438 \u0432 \u043f\u0430\u0440\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0443\u043d\u043a\u0442\u043e\u0432, \u0445\u043e\u0440\u043e\u0448\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u044d\u043f\u0438\u0437\u043e\u0434\u043e\u0432 <a href=\"http:\/\/railscasts.com\/episodes\/304-omniauth-identity\">RailsCasts<\/a>.<\/p>\n<pre><code class=\"bash\">$ rails g model user provider:string uid:string auth_token:string name:string $ rake db:migrate <\/code><\/pre>\n<p>  app\/models\/user.rb:  <\/p>\n<pre><code class=\"ruby\">class User &lt; ActiveRecord::Base   def self.from_omniauth(auth)     where(provider: auth.provider, uid: auth.uid).first_or_initialize.tap do |user|       user.auth_token = auth.credentials.token       user.name = auth.extra.raw_info.name       user.save!     end   end end <\/code><\/pre>\n<p>  6. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u0441\u0435\u0441\u0441\u0438\u0439. \u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u0433\u043e \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0441\u0435\u0441\u0441\u0438\u044e.<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434 create\u200a\u2014\u200a\u044d\u0442\u043e \u0442\u043e \u043c\u0435\u0441\u0442\u043e, \u043a\u0443\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u0435\u0433\u043e \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438. \u0422\u0443\u0442 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 from_omniauth, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u043c \u0448\u0430\u0433\u0435, \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0435\u0433\u043e \u0442\u043e\u043a\u0435\u043d, \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043a\u0443\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u044d\u0442\u0443 \u0441\u0435\u0441\u0441\u0438\u044e.<\/p>\n<pre><code class=\"bash\">$ rails g controller sessions <\/code><\/pre>\n<p>  app\/controllers\/sessions_controller.rb:  <\/p>\n<pre><code class=\"ruby\">class SessionsController &lt; ApplicationController   def create     user = User.from_omniauth(env[&quot;omniauth.auth&quot;])     cookies.permanent[:auth_token] = user.auth_token     redirect_to root_url   end   def destroy     cookies.delete(:auth_token)     redirect_to root_url   end   def index   end end <\/code><\/pre>\n<p>  \u041c\u043e\u0440\u0434\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u0443\u0441\u043a\u0430\u0439 \u043f\u043e\u043a\u0430 \u043f\u043e\u0436\u0438\u0432\u0435\u0442 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u0441\u0435\u0441\u0441\u0438\u0439, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0443\u0442 \u043c\u0435\u0442\u043e\u0434 index.<\/p>\n<p>  7. \u0427\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0442\u0435\u043a\u0443\u0449\u0435\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 ApplicationController \u043c\u0435\u0442\u043e\u0434 current_user, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u0449\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u0443\u043a\u0430 \u0441 \u0435\u0433\u043e \u0442\u043e\u043a\u0435\u043d\u043e\u043c.<\/p>\n<p>  app\/controllers\/application_controller.rb:  <\/p>\n<pre><code class=\"ruby\">helper_method :current_user def current_user   @current_user ||= User.find_by_auth_token(cookies[:auth_token]) if cookies[:auth_token] end <\/code><\/pre>\n<p>  8. \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043d\u0430 \u043c\u043e\u0440\u0434\u0435 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043b\u043e\u0433\u0438\u043d \u0438\u043b\u0438 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434.<\/p>\n<p>  app\/views\/sessions\/index.html.erb:  <\/p>\n<pre><code class=\"ruby\">&lt;% if current_user %&gt;   &lt;%= current_user.name %&gt;   &lt;%= link_to &quot;Log out&quot;, logout_path, method: :delete %&gt; &lt;% else %&gt;   &lt;%= link_to &quot;Auth with Coub&quot;, &quot;\/auth\/coub&quot; %&gt; &lt;% end %&gt; <\/code><\/pre>\n<p>  \u041f\u043e \u043f\u0443\u0442\u0438 \/auth\/coub \u0433\u0435\u043c omniauth-oauth2 \u043f\u0435\u0440\u0435\u0431\u0440\u043e\u0441\u0438\u0442 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0430 coub.com.<\/p>\n<p>  9. \u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0440\u043e\u0443\u0442\u044b:<\/p>\n<p>  config\/routes.rb:  <\/p>\n<pre><code class=\"ruby\">Rails.application.routes.draw do   root &quot;sessions#index&quot;   get &quot;\/auth\/:provider\/callback&quot; =&gt; &quot;sessions#create&quot;   delete &quot;logout&quot; =&gt; &quot;sessions#destroy&quot; end <\/code><\/pre>\n<p>  \u0421 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0432\u0441\u0435. \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u0430 <a href=\"http:\/\/memegenerator.dev\">memegenerator.dev<\/a>, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c. \u0414\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <iframe loading=\"lazy\" src=\"\/\/coub.com\/embed\/5ai5v?muted=false&#038;autostart=false&#038;originalSize=false&#038;hideTopBar=false&#038;startWithHD=false\" width=\"640\" height=\"360\" frameborder=\"0\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443 \u043d\u0430\u0441 \u0432 \u0431\u0430\u0437\u0435 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0447\u0435\u0440\u0435\u0437 Coub API.<\/p>\n<h2>\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043a API<\/h2>\n<p>  \u0418\u043c\u0435\u044f \u0442\u043e\u043a\u0435\u043d \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a API. \u042d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 HTTP, \u043a\u0430\u043a \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. GET \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u043e\u0436\u043d\u043e \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 \u0436\u0435 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041a\u0430\u0436\u0434\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a\u0440\u043e\u043c\u0435 \u0441\u0432\u043e\u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 access_token \u0441 \u0442\u043e\u043a\u0435\u043d\u043e\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u043c \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0434\u0430\u043b \u0441\u0435\u0440\u0432\u0435\u0440 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043b\u0430\u0439\u043a\u043d\u0443\u0442\u044c \u043a\u043e\u0431, \u043d\u0430\u0434\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441:  <\/p>\n<pre><code class=\"bash\">POST http:\/\/coub.com\/api\/v2\/likes?id=[coub_id]&channel_id=[channel_id]&access_token=[users_token] <\/code><\/pre>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0431\u0435\u0437 \u0442\u043e\u043a\u0435\u043d\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043d\u0444\u0430 \u043e \u043a\u043e\u0431\u0435 (\u0431\u0435\u0437 \u0442\u043e\u043a\u0435\u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0435 \u043a\u043e\u0431\u044b). \u042d\u0442\u043e GET \u0437\u0430\u043f\u0440\u043e\u0441, \u044d\u0442\u0443 \u0441\u0441\u044b\u043b\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435:  <\/p>\n<pre><code class=\"bash\">GET http:\/\/coub.com\/api\/v2\/coubs\/4yp6r <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0445\u043e\u0440\u043e\u0448\u043e \u0437\u0430\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442: <a href=\"http:\/\/coub.com\/dev\/docs\/Coub+API\/Overview\">coub.com\/dev\/docs\/Coub+API\/Overview<\/a><\/p>\n<h2>\u041a\u043b\u0438\u0435\u043d\u0442<\/h2>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u043e\u043a\u0435\u043d \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u0438 User \u043c\u0435\u0442\u043e\u0434 client, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b:<\/p>\n<p>  app\/models\/user.rb:  <\/p>\n<pre><code class=\"ruby\">def client   @client ||= Faraday.new(:url =&gt; &quot;http:\/\/coub.com\/api\/v2\/&quot;, :params =&gt; {:access_token =&gt; auth_token}) end <\/code><\/pre>\n<p>  Gemfile:  <\/p>\n<pre><code class=\"ruby\">gem &quot;faraday&quot; <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">$ bundle install <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 Faraday, \u044d\u0442\u043e HTTP \u043a\u043b\u0438\u0435\u043d\u0442 \u043d\u0430 Ruby.<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043a\u043e\u043d\u0441\u043e\u043b\u044c, \u043f\u043e\u0442\u0435\u0441\u0442\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0430\u043f\u0438:<\/p>\n<pre><code class=\"bash\">$ rails c &gt; user = User.first &gt; user.client.get &quot;coubs\/4yp6r&quot; <\/code><\/pre>\n<p>  \u041e\u0442\u0432\u0435\u0442\u044b \u0432\u044b\u0434\u0430\u044e\u0442\u0441\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON, \u043f\u043e\u044d\u0442\u043e\u043c\u0443, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0435\u0440\u043d\u0443\u043b \u0441\u0435\u0440\u0432\u0435\u0440, \u043d\u0430\u0434\u043e \u043e\u0442\u0432\u0435\u0442 \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 JSON \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439:<\/p>\n<pre><code class=\"ruby\">&gt; coub_info = JSON.parse(user.client.get(&quot;coubs\/4yp6r&quot;).body) &gt; coub_info[&quot;id&quot;] =&gt; 9090841 <\/code><\/pre>\n<p>  \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a \u043a\u043e\u0431\u0430, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0435\u0433\u043e \u043b\u0430\u0439\u043a\u043d\u0435\u043c:<\/p>\n<pre><code class=\"bash\">&gt; user.client.post &quot;likes?id=#{coub_info[&quot;id&quot;]}&quot; <\/code><\/pre>\n<h2>\u0413\u0435\u043d\u0435\u0440\u0438\u043c \u0432\u0438\u0434\u0435\u043e<\/h2>\n<p>  \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0432\u0438\u0434\u0435\u043e, \u043a\u0430\u0434\u0440 \u0438\u0437 \u0444\u0438\u043b\u044c\u043c\u0430, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043d\u0430 \u043d\u0435\u0433\u043e \u0442\u0440\u0438 \u0440\u0430\u0437\u0430 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0432 \u0440\u0430\u0437\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0432\u0438\u0434\u0435\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0435\u0441\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 ffmpeg, \u0432 \u043d\u0435\u0439 \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u0432\u0438\u0434\u0435\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e.<\/p>\n<p>  \u041d\u0430 \u043c\u0430\u043a\u0435 \u0447\u0435\u0440\u0435\u0437 Homebrew \u043e\u043d \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">$ brew install ffmpeg --with-freetype <\/code><\/pre>\n<p>  \u041d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442 \u0447\u0435\u0440\u0435\u0437 ffmpeg \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c drawtext:<\/p>\n<pre><code class=\"bash\">$ ffmpeg -i template.mp4 -vf &quot;drawtext=enable='between(t,1,2)':text=Blah:fontfile=PFDinTextCondPro-XBlack.ttf:fontsize=40:fontcolor=white:x=(w-tw)\/2:y=(h*0.9-th)&quot; output.mp4 <\/code><\/pre>\n<p>  \u042d\u0442\u0430 \u0441\u0442\u0440\u043e\u0447\u043a\u0430 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442:<\/p>\n<p>  1. <b>ffmpeg -i template.mp4 -vf<\/b>: \u0431\u0435\u0440\u0435\u043c \u0432\u0438\u0434\u0435\u043e \u0444\u0430\u0439\u043b\u0430 template.mp4. \u0424\u0430\u0439\u043b \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0432\u043e\u0442 \u0442\u0443\u0442.<\/p>\n<p>  2. <b>drawtext=enable<\/b>: \u043d\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0441\u0442<\/p>\n<p>  3. <b>between(t,1,2)<\/b>: \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u043e \u0432\u0442\u043e\u0440\u0443\u044e \u0441\u0435\u043a\u0443\u043d\u0434\u0443<\/p>\n<p>  4. <b>fontfile=PFDinTextCondPro-XBlack.ttf<\/b>: \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0444\u0430\u0439\u043b \u0441 \u0448\u0440\u0438\u0444\u0442\u043e\u043c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 TTF<\/p>\n<p>  5. <b>text=Blah<\/b>: \u043f\u0438\u0448\u0435\u043c \u0442\u0435\u043a\u0441\u0442 Blah<\/p>\n<p>  6. <b>fontsize=40<\/b>: \u0440\u0430\u0437\u043c\u0435\u0440 \u0448\u0440\u0438\u0444\u0442\u0430<\/p>\n<p>  7. <b>fontcolor=white<\/b>: \u0431\u0435\u043b\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430<\/p>\n<p>  8. <b>x=(w-tw)\/2:y=(h*0.9-th)<\/b>: \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u0435\u043a\u0441\u0442\u0430 \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u0432\u043d\u0438\u0437\u0443 (w \u0438 h\u200a\u2014\u200a\u044d\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u0438\u0434\u0435\u043e, tw \u0438 th\u200a\u2014\u200a\u044d\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u043b\u043e\u043a\u0430 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u043c)<\/p>\n<p>  9. <b>output.mp4<\/b>: \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0432 \u044d\u0442\u043e\u0442 \u0444\u0430\u0439\u043b<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0440\u0438 \u0442\u0435\u043a\u0441\u0442\u0430, \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e \u0442\u0440\u0438 drawtext \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c:<\/p>\n<pre><code class=\"bash\">$ ffmpeg -i template.mp4 -vf &quot;drawtext=enable='between(t,1,2)':text=Text1:fontfile=PFDinTextCondPro-XBlack.ttf:fontsize=40:fontcolor=white:x=(w-tw)\/2:y=(h*0.9-th), drawtext=enable='between(t,3,5)':text=Text2:fontfile=PFDinTextCondPro-XBlack.ttf:fontsize=40:fontcolor=white:x=(w-tw)\/2:y=(h*0.9-th), drawtext=enable='between(t,6.3,8)':text=Text3:fontfile=PFDinTextCondPro-XBlack.ttf:fontsize=40:fontcolor=white:x=(w-tw)\/2:y=(h*0.9-th)&quot; output.mp4 <\/code><\/pre>\n<p>  \u0412 \u0442\u0435\u043c\u043f\u043e\u0432\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u0444\u0430\u0439\u043b template.mp4 \u0438 \u0444\u0430\u0439\u043b \u0448\u0440\u0438\u0444\u0442\u0430 (\u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043b\u044e\u0431\u043e\u0439 TTF \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 \u0441\u043e \u0448\u0440\u0438\u0444\u0442\u0430\u043c\u0438) \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c, \u043e\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0435 \u0432\u0438\u0434\u0435\u043e.<\/p>\n<h2>\u0417\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0432\u0438\u0434\u0435\u043e<\/h2>\n<p>  \u0412\u0438\u0434\u0435\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0434\u043e \u0438\u0437 \u043d\u0435\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0431.<\/p>\n<p>  \u041a\u043e\u0431 \u0447\u0435\u0440\u0435\u0437 API \u0437\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0440\u0438 \u044d\u0442\u0430\u043f\u0430:<\/p>\n<p>  1. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043a\u0430\u0447\u043a\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c POST coubs\/init_upload, \u0432 \u043e\u0442\u0432\u0435\u0442\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c id \u043a\u043e\u0431\u0430 \u0438 \u0435\u0433\u043e permalink.  <\/p>\n<pre><code class=\"ruby\">$ rails c &gt; user = User.first &gt; init_response = JSON.parse(user.client.post(&quot;coubs\/init_upload&quot;).body) &gt; coub_id = init_response[&quot;id&quot;] &gt; permalink = init_response[&quot;id&quot;] <\/code><\/pre>\n<p>  2. \u0417\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u0432\u0438\u0434\u0435\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c POST coubs\/:id\/upload_video. \u0424\u0430\u0439\u043b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u0435\u043b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432 \u0445\u0435\u0434\u0435\u0440\u0435 Content-Type \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c video\/mp4:<\/p>\n<pre><code class=\"bash\">&gt; user.client.post do |r|    r.url &quot;coubs\/#{coub_id}\/upload_video&quot;    r.headers[&quot;Content-Type&quot;] = &quot;video\/mp4&quot;    r.body = File.open(&quot;tmp\/output.mp4&quot;, &quot;r&quot;).read  end <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0430\u0443\u043d\u0434\u0442\u0440\u0435\u043a \u043a \u043a\u043e\u0431\u0443, \u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c coubs\/:id\/upload_audio. \u041d\u0430\u043c \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u044d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<p>  3. \u0424\u0438\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u0431\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c POST coubs\/:id\/finalize_upload, \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0442\u0430\u0439\u0442\u043b, \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0441\u0442\u0438, \u0442\u0435\u0433\u0438, \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u043b\u0438 \u0437\u0432\u0443\u043a.<\/p>\n<pre><code class=\"bash\">&gt; user.client.post &quot;coubs\/#{coub_id}\/finalize_upload&quot;, title: &quot;Test coub&quot;, original_visibility_type: &quot;private&quot;, tags: &quot;tag1, tag2, tag3&quot;, sound_enabled: true <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u043a\u0430\u0447\u043a\u0438 \u043a\u043e\u0431\u0430, \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u0442\u044c\u0441\u044f: \u0432\u0438\u0434\u0435\u043e \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0430\u0445 \u041a\u043e\u0431\u0430 \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c, \u0431\u0443\u0434\u0443\u0442 \u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0435\u0432\u044c\u044e\u0448\u043a\u0438 \u0438 \u043a\u0443\u0447\u0430 \u0432\u0441\u044f\u043a\u0438\u0445 \u0442\u0430\u043a\u0438\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0435\u043c\u043a\u0438\u0445 \u0432\u0435\u0449\u0435\u0439. \u041f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c GET \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c coubs\/:id\/finalize_status. \u041e\u043d \u043e\u0442\u0434\u0430\u0435\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 JSON { percent_done: 20, done: false}.<\/p>\n<pre><code class=\"bash\">&gt; user.client.get &quot;coubs\/#{coub_id}\/finalize_status&quot; <\/code><\/pre>\n<p>  \u041e\u043a. \u041c\u044b \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u044d\u0442\u043e \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438, \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u043d\u0430\u0434\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435.<\/p>\n<h2>\u041c\u043e\u0434\u0435\u043b\u044c Coub<\/h2>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0435\u043b\u044c Coub:<\/p>\n<pre><code class=\"bash\">$ rails g model coub user:belongs_to title:string visibility_type:string tags:string permalink:string coub_id:string text1:string text2:string text3:string $ rake db:migrate <\/code><\/pre>\n<p>  2. \u0414\u0435\u043b\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 generate_video_file, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0435\u0440\u0435\u043d\u0438\u0442 \u0432\u0438\u0434\u0435\u043e \u0438\u0437 \u0432\u0438\u0434\u0435\u043e-\u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0438 \u0442\u0440\u0435\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u0432, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u0432 \u043f\u043e\u043b\u044f\u0445 text1, text2, text3. \u0428\u0430\u0431\u043b\u043e\u043d \u0432\u0438\u0434\u0435\u043e \u0438 \u0448\u0440\u0438\u0444\u0442 \u043a\u043b\u0430\u0434\u0435\u043c \u0432 \u0430\u0441\u0441\u0435\u0442\u044b. \u0413\u043e\u0442\u043e\u0432\u043e\u0435 \u0432\u0438\u0434\u0435\u043e \u043a\u043b\u0430\u0434\u0435\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 tmp.<\/p>\n<p>  app\/models\/coub.rb:  <\/p>\n<pre><code class=\"ruby\">def escape_ffmpeg_text(text)   text.to_s.gsub(&quot;'&quot;, &quot;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'&quot;).gsub(&quot;:&quot;, &quot;\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\:&quot;).mb_chars.upcase # Crazy ffmpeg escaping end def ffmpeg_drawtext(text, from, to)   font_file = File.join(Rails.root, &quot;app&quot;, &quot;assets&quot;, &quot;fonts&quot;, &quot;PFDinTextCondPro-XBlack.ttf&quot;)   &quot;drawtext=enable='between(t,#{from},#{to})':text=#{escape_ffmpeg_text(text)}:fontfile=#{font_file}:fontsize=40:fontcolor=white:x=(w-tw)\/2:y=(h*0.9-th)&quot; end def generate_video_file   self.video_file = File.join(Rails.root, &quot;tmp&quot;, &quot;output-#{Time.now.to_i}.mp4&quot;)   template_file = File.join(Rails.root, &quot;app&quot;, &quot;assets&quot;, &quot;videos&quot;, &quot;template.mp4&quot;)   `ffmpeg -i #{template_file} -vf \\&quot;#{ffmpeg_drawtext(text1, 1, 2)}, #{ffmpeg_drawtext(text2, 3, 5)}, #{ffmpeg_drawtext(text3, 6.3, 8)}\\&quot; #{video_file}`   return video_file end <\/code><\/pre>\n<p>  3. \u0414\u0435\u043b\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0442\u0440\u0438 \u044d\u0442\u0430\u043f\u0430 \u0437\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442 \u0432\u0438\u0434\u0435\u043e \u043d\u0430 \u041a\u043e\u0431:<\/p>\n<p>  app\/models\/coub.rb:  <\/p>\n<pre><code class=\"ruby\">def upload_video   self.title ||= text2   self.visibility_type ||= &quot;private&quot;   self.tags ||= &quot;&quot;      init_response = JSON.parse(client.post(&quot;coubs\/init_upload&quot;).body)   self.coub_id = init_response[&quot;id&quot;]   self.permalink = init_response[&quot;permalink&quot;]      save   client.post do |r|     r.url &quot;coubs\/#{coub_id}\/upload_video&quot;     r.headers[&quot;Content-Type&quot;] = &quot;video\/mp4&quot;     r.body = File.open(video_file, &quot;r&quot;).read   end   client.post &quot;coubs\/#{coub_id}\/finalize_upload&quot;,     title: title,     original_visibility_type: visibility_type,     tags: tags,     sound_enabled: true end def generate_and_upload_video   generate_video_file   upload_video end <\/code><\/pre>\n<p>  4. \u041f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u043a\u043e\u0431 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0438 \u0437\u0430\u043e\u0434\u043d\u043e \u043f\u0438\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434 client \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u043d\u043e\u0433\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u0447\u0435\u0440\u0435\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f:<\/p>\n<p>  app\/models\/coub.rb:  <\/p>\n<pre><code class=\"ruby\">belongs_to :user def client   @client ||= user.client end <\/code><\/pre>\n<p>  5. \u041c\u0435\u0442\u043e\u0434 url \u043e\u0442\u0434\u0430\u0435\u0442 \u0443\u0440\u043b \u043a\u043e\u0431\u0430 \u043f\u043e \u043f\u0435\u0440\u043c\u0430\u043b\u0438\u043d\u043a\u0443:<\/p>\n<p>  app\/models\/coub.rb:  <\/p>\n<pre><code class=\"ruby\">def url   &quot;http:\/\/coub.com\/view\/#{permalink}&quot; end <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0432\u0441\u0435 \u043b\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<pre><code class=\"bash\">$ rails c &gt; coub = Coub.new &gt; coub.user = User.first &gt; coub.text1 = 'Text 1' &gt; coub.text2 = 'Text 2' &gt; coub.text3 = 'Text 3' &gt; coub.tags = 'tag1, tag2, tag3' &gt; coub.visibility_type = 'unlisted' &gt; coub.generate_and_upload_video &gt; coub.url =&gt; &quot;http:\/\/coub.com\/view\/5dbyc&quot; <\/code><\/pre>\n<p>  \u041f\u043e \u044d\u0442\u043e\u043c\u0443 \u0443\u0440\u043b\u0443 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0439\u0442\u0438 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0441\u0438\u043d\u0438\u0439 \u044d\u043a\u0440\u0430\u043d \u201cYour coub is being processed\u201d.<\/p>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440:<\/p>\n<p>  1. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 coubs. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u0434\u0432\u0443\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432: index (\u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u043e\u0432\u0430\u044f \u043c\u043e\u0440\u0434\u0430, \u0432\u043c\u0435\u0441\u0442\u043e sessions#index) \u0438 create. \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043e\u0431\u0430 \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0440\u0435\u0434\u0438\u0440\u0435\u043a\u0442\u0438\u043c \u043d\u0430 \u043d\u0435\u0433\u043e.<\/p>\n<pre><code class=\"bash\">$ rails g controller coubs <\/code><\/pre>\n<p>  app\/controllers\/coubs_controller.rb:  <\/p>\n<pre><code class=\"ruby\">class CoubsController &lt; ApplicationController   def index   end   def create     @coub = Coub.create(coub_params.merge(:user =&gt; current_user))     @coub.generate_and_upload_video     redirect_to @coub.url   end private   def coub_params     params.require(:coub).permit(:text1, :text2, :text3, :visibility_type, :tags)   end end <\/code><\/pre>\n<p>  2. \u041f\u0435\u0440\u0435\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u043c index.html.erb \u0438\u0437 sessions \u0432 coubs \u0438 \u043f\u0440\u0438\u043a\u0440\u0443\u0447\u0438\u0432\u0430\u0435\u043c \u0442\u0443\u0434\u0430 \u0444\u043e\u0440\u043c\u0443:<\/p>\n<p>  app\/views\/coubs\/index.html.erb:  <\/p>\n<pre><code class=\"ruby\">&lt;% if current_user %&gt;   &lt;p&gt;You\u2019re logged in as &lt;%= current_user.name %&gt;. &lt;%= link_to &quot;Log out&quot;, logout_path, method: :delete %&gt;&lt;\/p&gt;     &lt;%= form_for Coub.new, url: {action: &quot;create&quot;} do |f| %&gt;     &lt;%= f.text_field :text1, placeholder: &quot;To me&quot;, maxlength: 30, size: 50 %&gt;&lt;br \/&gt;     &lt;%= f.text_field :text2, placeholder: &quot;Your Coub API&quot;, maxlength: 30, size: 50 %&gt;&lt;br \/&gt;     &lt;%= f.text_field :text3, placeholder: &quot;Is a piece of shit&quot;, maxlength: 30, size: 50 %&gt;&lt;br \/&gt;     &lt;%= f.select :visibility_type, options_for_select([&quot;public&quot;, &quot;friends&quot;, &quot;unlisted&quot;, &quot;private&quot;]) %&gt;&lt;br \/&gt;     &lt;%= f.text_field :tags, placeholder: &quot;first tag, second tag&quot; %&gt;&lt;br \/&gt;     &lt;%= f.submit &quot;Create Coub&quot; %&gt;   &lt;% end %&gt; &lt;% else %&gt;   &lt;p&gt;Please &lt;a href=&quot;\/auth\/coub&quot;&gt;log in via Coub&lt;\/a&gt;.&lt;\/p&gt; &lt;% end %&gt; <\/code><\/pre>\n<p>  \u0412\u0441\u0435, \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440, \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<p>  <iframe loading=\"lazy\" src=\"\/\/coub.com\/embed\/5dd0n?muted=false&#038;autostart=false&#038;originalSize=false&#038;hideTopBar=false&#038;startWithHD=false\" width=\"640\" height=\"360\" frameborder=\"0\" allowfullscreen=\"true\"><\/iframe><br \/>  \u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u044f \u043e\u043f\u0438\u0441\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0440\u0430\u0431\u043e\u0442\u044b API. \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u0434\u043b\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u0434\u043e \u0435\u0449\u0435 \u043c\u043d\u043e\u0433\u043e \u0447\u0435\u0433\u043e \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c: \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u043e\u0432 API, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0448\u0438\u0431\u043e\u043a, \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c, \u0442\u0435\u0441\u0442\u044b. \u0427\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u0434\u043e\u043f\u0438\u043b\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430 \u043b\u0435\u0436\u0438\u0442 \u0432\u043e\u0442 \u0442\u0443\u0442 <a href=\"http:\/\/fantozzi.dev2.workisfun.ru\">http:\/\/fantozzi.dev2.workisfun.ru<\/a>, \u0442\u0430\u043c \u0432\u0441\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u0432\u0438\u0434\u0435\u043e \u0433\u043e\u0442\u043e\u0432\u0438\u0442\u0441\u044f \u0438 \u0437\u0430\u043a\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e \u0447\u0435\u0440\u0435\u0437 delayed_job.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0433\u0438\u0442\u0445\u0430\u0431\u0435: <a href=\"https:\/\/github.com\/igorgladkoborodov\/memegenerator\/\">https:\/\/github.com\/igorgladkoborodov\/memegenerator\/<\/a>.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0443 \u0438\u043b\u0438 \u043f\u043e API, \u043f\u0438\u0448\u0438\u0442\u0435 \u043d\u0430 <a href=\"mailto:igor@coub.com\">igor@coub.com<\/a>.      \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/252803\/\"> http:\/\/habrahabr.ru\/post\/252803\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t\u041d\u0430 \u0434\u043d\u044f\u0445 \u043c\u044b \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b\u0438 <a href=\"http:\/\/coub.com\/dev\/docs\/Coub+API\/Overview\">Coub API<\/a>. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043b\u0435\u043d\u0442\u0443, \u043b\u0430\u0439\u043a\u0430\u0442\u044c, \u0440\u0435\u043a\u043e\u0431\u0438\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430 \u0441\u0430\u0439\u0442\u0435, \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 API. \u041d\u043e \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435\u200a\u2014\u200a\u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0438\u0437 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 API \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u0431\u044b.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0435 \u044f \u043f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u043a\u043e\u0431\u0430 \u043d\u0430 Ruby on Rails. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043b\u043e\u0433\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0431 \u0438 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0431 \u0441 \u043b\u044e\u0431\u044b\u043c \u0442\u0435\u043a\u0441\u0442\u043e\u043c:<\/p>\n<p>  <iframe loading=\"lazy\" src=\"\/\/coub.com\/embed\/5eoxr?muted=false&#038;autostart=false&#038;originalSize=false&#038;hideTopBar=false&#038;startWithHD=false\" width=\"640\" height=\"360\" frameborder=\"0\" allowfullscreen=\"true\"><\/iframe><\/p>\n<p>  \u0420\u0430\u0431\u043e\u0447\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043b\u0435\u0436\u0438\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 <a href=\"http:\/\/fantozzi.dev2.workisfun.ru\">fantozzi.dev2.workisfun.ru<\/a>, \u043a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u0413\u0438\u0442\u0445\u0430\u0431\u0435: <a href=\"https:\/\/github.com\/igorgladkoborodov\/memegenerator\">github.com\/igorgladkoborodov\/memegenerator<\/a>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-253021","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253021","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=253021"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/253021\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=253021"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=253021"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=253021"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}