Guest User

Untitled

a guest
Aug 31st, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. Finding out the destination YouTube URL when uploading videos to YouTube via youtube_it gem with Rails
  2. def create
  3. @video = Video.new(params[:video])
  4. if @video.save
  5. uploader = YouTubeIt::Upload::VideoUpload.new( :username => AppConfig[:youtube_user],
  6. :password => AppConfig[:youtube_pass],
  7. :dev_key => AppConfig[:youtube_api_key])
  8. uploader.upload open( params[:video][:attachment] ), :title => @video.title,
  9. :description => @video.description,
  10. :category => 'some category',
  11. :keywords => ['some keyword 1', "some keyword 2"]
  12. @video.deliver_video_notification
  13. flash[:notice] = 'Your video is under review for approval.<br/> Please check back in 48 hours.'
  14. redirect_to videos_url
  15. else
  16. @errors = @video.errors
  17. @current_video = params[:v].blank? ? Video.newest : Video.find(params[:v])
  18. render :action => :index
  19. end
  20. end
  21.  
  22. def create
  23. @video = Video.new(params[:video])
  24. if @video.save
  25. uploader = YouTubeIt::Upload::VideoUpload.new( :username => AppConfig[:youtube_user],
  26. :password => AppConfig[:youtube_pass],
  27. :dev_key => AppConfig[:youtube_api_key])
  28. uploaded_video = uploader.upload open( params[:video][:attachment] ), :title => @video.title,
  29. :description => @video.description,
  30. :category => 'some category',
  31. :keywords => ['some keyword 1', "some keyword 2"]
  32.  
  33. puts uploaded_video.player_url # This will print the URL to the log
  34.  
  35. @video.deliver_video_notification
  36. flash[:notice] = 'Your video is under review for approval.<br/> Please check back in 48 hours.'
  37. redirect_to videos_url
  38. else
  39. @errors = @video.errors
  40. @current_video = params[:v].blank? ? Video.newest : Video.find(params[:v])
  41. render :action => :index
  42. end
  43. end
Add Comment
Please, Sign In to add comment