<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/g_data.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/auth/authsub.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/auth/clientlogin.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/apps.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/base.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/blogger.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/booksearch.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/calendar.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/contacts.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/doclist.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/finance.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/gbase.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/gmail.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/health.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/notebook.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/photos.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/spreadsheets.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/webmaster_tools.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/client/youtube.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/g_data.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/http.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/http/default_service.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/http/mime_body.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/http/request.rb</filename>
    </added>
    <added>
      <filename>lib/gdata/http/response.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,32 +1,12 @@
 h1. YouTube Model
 
 This plugin allows you to interact with the new YouTube API (yes, that means uploading is now featured)
-through a simple ActiveResource model.
-
-h2. Patch for Rails 2.1.1
-
-There was a change in Rails 2.1.1 that causes a **406 Not Acceptable HTTP error**. There is a patch
-to solve this though.
-
-Just apply the patch to your frozen copy of rails:
-
-  curl http://rails.lighthouseapp.com/attachments/46685/http_accept_header.diff | git am
-
-See details &quot;here&quot;:http://groups.google.com/group/rubyonrails-core/browse_thread/thread/38a853b997202b3
-
-**Note about wikis and docs**
-
-Currently, the wikis are empty. So I'd appreciate if you want to contribute with wikis documentation; just drop me
-a line at edgar.js[at]gmail.com.
-
-But, it doesn't mean there isn't enough documentation. The full plugin is _rdoced_ so you just can @rake rdoc@ and
-check the details.
-
-*********************************************************************
+through a simple ActiveResource model. It also saves the metadata locally of any video uploaded to youtube.
+The video can then be updated and deleted. The changes will be reflected at the youtube.  
 
 h2. Repository
 
-Find it at &quot;http://github.com/edgarjs/youtube-model&quot;:http://github.com/edgarjs/youtube-model
+Find it at &quot;http://github.com/vibha/youtube-model&quot;:http://github.com/vibha/youtube-model
 
 h2. Documentation
 
@@ -34,7 +14,7 @@ h3. Installing
 
 Simply as:
 
-  ./script/plugin install git://github.com/edgarjs/youtube-model.git
+  ./script/plugin install git://github.com/vibha/youtube-model.git
 
 h3. Generating the system
 
@@ -50,47 +30,58 @@ This generator will create four files:
 And that's all, but be sure to check the configuration file to set up your Developer and Client Keys.
 You can get these keys at the &quot;YouTube APIs and Tools&quot;:http://code.google.com/apis/youtube/dashboard/ page.
 
-h3. Listing videos
-
-Let's say you generated a model named YouTube. So now you can use that model very similar
-to an ActiveRecord model.
+h3 AuthSub for web applications
 
-To search for videos passing a simple query use the method @find@
+	A link is provided to authorise the website to access to the logged in user's youtube account.
+	
+	The token obtained after doing authorisation process will become a session token. So we will set the session parameter to 1 in yaml	configuration file. This token is used to upload, edit and delete video.
 
-  YouTube.find('rails conference 2008')
+	#app/views/videos/index.html.erb
 
-To get the videos uploaded by a user you can use the method @uploaded_by@ passing the username
+	Please Click &lt;%= link_to 'here', youtube_auth_url(authorise_video_url) %&gt; first to authorise access to your youtube account.&lt;br/&gt;
 
-  YouTube.uploaded_by('envyads')
+	An authorise method will be added to make the single use token to a session token.
 
-And so on. To see the full list of available methods see the &quot;rdoc&quot;:http://rdoc.info/projects/edgarjs/youtube-model
+	&lt;pre&gt;&lt;code&gt;
+	#VideosController
+	
+		include GData
+		
+		def authorise
+	    client = GData::Client::DocList.new
+	    if params[:token] 
+	      client.authsub_token = params[:token] # extract the single-use token from the URL query params 
+	      session[:token] = client.auth_handler.upgrade() 
+	      client.authsub_token = session[:token] if session[:token]      
+	    end
+	    redirect_to videos_path
+	  end
 
-All methods will return an instance of @Entry@. The @Entry@ object encapsulates information about a video, playlist,
-suscription, contact or other entity. This class is parsed from the @&lt;entry&gt;@ tag of the xml response, wich is the root
-tag in all YouTube data API requests. (To see more about the structure of the xml response go
-to the &quot;YouTube API&quot;:http://code.google.com/apis/youtube/developers_guide_protocol.html#Understanding_Video_Entries
+		gdata is a gem which is used here for authorisation process. 
 
-The returned model instance has a main mehod: **videos**, wich is more than an alias for @entry@.
+h3. Listing videos
 
 **Example**
+  
+To get the videos uploaded by a user you can use the method @uploaded_by_user@ passing the session[:token] we saved during authorisation process
+
+  YouTube.uploaded_by_user(session[:token])
 
-  &lt;pre&gt;&lt;code&gt;
-  #VideosController
   def index
-    @youtube = YouTube.find('ruby on rails', :max_results =&gt; 5)
+    @youtube =YouTube.uploaded_by_user(session[:token])
   end
-  
-  def show
-    @video = YouTube.find_by_id(params[:id])
-  end
-  
+ 
+	def show
+		@video = YouTube.find_by_id(params[:id]) rescue nil
+		flash[:message] = &quot;Sorry the video is not found at Youtube&quot; and redirect_to videos_path unless @video
+	end
+	
   #app/views/videos/index.html.erb
   &lt;%= image_tag @youtube.logo %&gt;
   
   &lt;h1&gt;&lt;%= @youtube.title %&gt;&lt;/h1&gt;
   &lt;%= &quot;Displaying #{@youtube.startIndex} - #{@youtube.itemsPerPage} of #{@youtube.totalResults}&quot; %&gt;
-  
-  &lt;%= link_to 'Upload', youtube_auth_url(new_video_url) %&gt;
+
   &lt;% for video in @youtube.videos %&gt;
     &lt;h3&gt;&lt;%= video.title %&gt;&lt;/h3&gt; in &lt;%= video.group.category %&gt;
     by &lt;%= link_to video.author.name, &quot;http://youtube.com/#{video.author.name}&quot; %&gt;
@@ -99,12 +90,16 @@ The returned model instance has a main mehod: **videos**, wich is more than an a
     &lt;%= link_to image_tag(video.group.thumbnail.first.url, :alt =&gt; video.title), video_path(video.id) %&gt;
     &lt;%= link_to 'Watch on youtube', video.link.first.href %&gt;
   &lt;% end %&gt;
-  
+
   #app/views/videos/show.html.erb
-  &lt;h1&gt;&lt;%= @video.title %&gt;&lt;/h1&gt;
-  by &lt;%= link_to @video.author.name, &quot;http://youtube.com/#{@video.author.name}&quot; %&gt;
-  &lt;%= youtube_embed @video %&gt;
-  &lt;%= link_to 'Back', videos_path %&gt;
+
+	&lt;h1&gt;&lt;%= @video.title %&gt;&lt;/h1&gt;
+	by &lt;%= link_to @video.author.name, &quot;http://youtube.com/#{@video.author.name}&quot; %&gt;
+	&lt;%= youtube_embed @video %&gt;
+	
+	&lt;%= link_to 'Back', videos_path %&gt;&lt;br/&gt;
+	&lt;%= link_to 'Edit/Update', edit_video_path(@video) %&gt;&lt;br/&gt;
+	&lt;%= link_to 'Delete', video_path(@video), :method =&gt; &quot;delete&quot; %&gt;&lt;br/&gt;
   &lt;/code&gt;&lt;/pre&gt;
 
 As you can see, the @youtube_embed@ method is used to display a video.
@@ -124,11 +119,11 @@ So basically we have two actions in our controller to upload a video. Here's a q
 
   &lt;pre&gt;&lt;code&gt;
   #routes.rb
-  map.resources :videos, :new =&gt; {:upload =&gt; :post}
+  map.resources :videos, :new =&gt; {:upload =&gt; :post}, :member =&gt; {:authorise =&gt; :get }
   
   #VideosController
   def new
-    @categories ||= YouTube.categories_collection
+    @categories ||= YouTube.video_categories
   end
   
   def upload
@@ -137,13 +132,13 @@ So basically we have two actions in our controller to upload a video. Here's a q
   
   #app/views/videos/new.html.erb
   &lt;% form_for 'video', :url =&gt; upload_new_video_path do |f| %&gt;
-    &lt;%= f.hidden_field :auth_sub, :value =&gt; params[:token] %&gt;
+    &lt;%= f.hidden_field :auth_sub, :value =&gt; session[:token] %&gt;
     
     &lt;%= f.label :title %&gt;
     &lt;%= f.text_field :title %&gt;
   
     &lt;%= f.label :description %&gt;
-    &lt;%= f.text_area :description, :rows =&gt; 10 %&gt;
+    &lt;%= f.text_area :content, :rows =&gt; 10 %&gt;
   
     &lt;%= f.label :category %&gt;
     &lt;%= f.select :category, @categories %&gt;
@@ -153,7 +148,7 @@ So basically we have two actions in our controller to upload a video. Here's a q
   
     &lt;%= f.submit 'Continue to Step 2' %&gt;
   &lt;% end %&gt;
-  
+
   #app/views/videos/upload.html.erb
   &lt;% form_tag @upload_info[:url], :multipart =&gt; true do %&gt;
     &lt;%= hidden_field_tag :token, @upload_info[:token] %&gt;
@@ -165,25 +160,97 @@ So basically we have two actions in our controller to upload a video. Here's a q
   &lt;% end %&gt;
   &lt;/code&gt;&lt;/pre&gt;
 
-Pay special attention to the routes file, I've added a new route called @:upload@ so I can use it
-in the first step to set the form post url by calling @upload_new_video_path@.
-Also don't forget to set @:multipart =&gt; true@ in the second step.
+h3 Updating Videos
+	
+	To get the videos updated by a user you can use the method @update_video@ passing the id of that video, session[:token] and params hash
+
+	  YouTube.update_video(params[:id], session[:token], params[:you_tube_entry])
+	
+	#VideosController
+	
+		before_filter :find_video, :only =&gt; [:edit, :update]
+	
+		def edit
+		  @youtube_videos =YouTube.uploaded_by_user(session[:token])
+		  @video = @youtube_videos.videos.select { |video| video.id == params[:id] }  
+		  @youtube = @video.first
+		  @youtube.keywords = @youtube.group.keywords
+		  @youtube.category = @youtube.group.category
+		  @categories ||= YouTube.video_categories
+		end
+
+		def update
+		  if u = YouTube.update_video(params[:id], session[:token], params[:you_tube_entry])
+		    flash[:message] = &quot;Video has been Updated Successfully.&quot;
+		  else
+		    flash[:message] = &quot;Video not Updated Successfully.&quot;
+		  end      
+		  redirect_to videos_path
+		end
+
+		Also add a filter before these methods to find the video as find_video which is private
+		
+		private
+		def find_video
+		  unless @video = YouTube.find_by_id(params[:id]) rescue nil
+		    flash[:message] = &quot;Sorry the video is not found at Youtube&quot; and redirect_to videos_path 
+		  end
+		end
+		
+	#app/views/videos/edit.html.erb
+	&lt;p&gt;
+	&lt;fieldset&gt;
+	  &lt;legend&gt;Edit Video&lt;/legend&gt;
+	
+		Please Enter all the fields of the form.
+			
+		&lt;% form_for @youtube, :url =&gt; video_url, :html =&gt; { :multipart =&gt; true }  do |f| %&gt;
+		
+		  &lt;%= f.label :title %&gt;
+		  &lt;%= f.text_field :title %&gt;
+		
+		  &lt;%= f.label :description %&gt;
+		  &lt;%= f.text_area :content, :rows =&gt; 10 %&gt;
+		
+		  &lt;%= f.label :category %&gt;
+		  &lt;%= f.select :category, @categories %&gt;
+	
+		  &lt;%= f.label :keywords %&gt;
+		  &lt;%= f.text_field :keywords %&gt;
+	
+  		&lt;%= f.submit 'Update video' %&gt;
+
+	 &lt;% end %&gt;
+	&lt;/fieldset&gt;
+	
+	&lt;%= link_to 'Back', videos_path %&gt;
+
+h3 Deleting Videos
+
+To delete the videos of any user you can use the method @delete_video@ passing the id of that video and session[:token]
+
+  YouTube.delete_video(params[:id], session[:token])
+
+	#VideosController
+		
+		before_filter :find_video, :only =&gt; [:show, :edit, :update, :destroy]
+		
+		def destroy  
+		  yt = YouTube.delete_video(params[:id], session[:token]) rescue nil
+		  flash[:message] = &quot;Video has been sucessfully deleted.&quot; if yt.msg == &quot;OK&quot;
+		  redirect_to videos_path
+		end
+
+	The show method can be removed as the video is found inside the filter method which is applied on show method as well.
 
-Very easy isn't it? Yep, that is all.
+Also don't forget to set @:multipart =&gt; true@ in the second step.
 
 And for a more specific speech... the class method @get_upload_url@ receives a hash containing
 the meta-info of the first step, and returns a hash with the upload url and token.
 
-For extra information don't forget to read the &quot;wikis&quot;:http://github.com/edgarjs/youtube-model/wikis
-or if you wanna go further just generate the rdoc for the plugin, it will be uber helpful.
-
 h2. Feedback
 
-I'll really appreciate your feedback, please contact me at edgar.js[at]gmail.com
-
-h3. Special Thanks
-
-I'd like to thank Tal Pink for the nice contribution to the plugin. It was the motivation for finish up this first version! :) Thank you very much.
+I'll really appreciate your feedback, please contact me at vibha[at]vinsol.com
 
 h2. License
 </diff>
      <filename>README.textile</filename>
    </modified>
    <modified>
      <diff>@@ -184,13 +184,17 @@ module YouTubeModel # :nodoc:
       request(&quot;videos/#{id}&quot;)
     end
     
-    # Fetchs all YouTube categories
-    def categories
+    # Fetchs few YouTube categories
+    def video_categories
       [[&quot;Film &amp; Animation&quot;, &quot;Film&quot;], [&quot;Autos &amp; Vehicles&quot;, &quot;Autos&quot;], [&quot;Music&quot;, &quot;Music&quot;], [&quot;Pets &amp; Animals&quot;, &quot;Animals&quot;], [&quot;Sports&quot;, &quot;Sports&quot;],
       [&quot;Travel &amp; Events&quot;, &quot;Travel&quot;], [&quot;News &amp; Politics&quot;, &quot;News&quot;], [&quot;Howto &amp; Style&quot;, &quot;Howto&quot;], [&quot;Gaming&quot;, &quot;Games&quot;], [&quot;Comedy&quot;, &quot;Comedy&quot;], 
       [&quot;People &amp; Blogs&quot;, &quot;People&quot;], [&quot;Entertainment&quot;, &quot;Entertainment&quot;], [&quot;Education&quot;, &quot;Education&quot;], [&quot;Nonprofits &amp; Activism&quot;, &quot;Nonprofit&quot;], 
       [&quot;Science &amp; Technology&quot;, &quot;Tech&quot;]]
-    #  connection.get('/schemas/2007/categories.cat')['category']
+    end
+    
+    # Fetchs all YouTube categories
+    def categories
+      connection.get('/schemas/2007/categories.cat')['category']
     end
     
     # Returns an array with only the +label+ and +term+ attributes of categories.
@@ -235,13 +239,14 @@ module YouTubeModel # :nodoc:
       upload
     end
     
+    
     def delete_video(video_id, token)
-      delete_request_with_authorised_user(&quot;users/default/uploads/#{video_id}&quot;, token)
+      delete_request_with_user_as_default(&quot;users/default/uploads/#{video_id}&quot;, token)
     end
     
     def update_video(video_id, token, video_params)
       xml_entry = build_xml_entry(video_params)
-      put_request_with_authorised_user(&quot;users/default/uploads/#{video_id}&quot;, token, xml_entry)
+      put_request_with_user_as_default(&quot;users/default/uploads/#{video_id}&quot;, token, xml_entry)
     end
     
     # Find status of video uploaded by a user.
@@ -261,7 +266,7 @@ module YouTubeModel # :nodoc:
       new.load(extend_attributes(connection.get(url, 'Accept' =&gt; '*/*')))
     end
     
-    def put_request_with_authorised_user(url, token, meta)
+    def put_request_with_user_as_default(url, token, meta)
       headers = {
         'Content-Type' =&gt; &quot;application/atom+xml&quot;,
         'Content-Length' =&gt; meta.length.to_s,
@@ -273,7 +278,7 @@ module YouTubeModel # :nodoc:
       connection.put(url, meta, headers) rescue nil
     end
     
-    def delete_request_with_authorised_user(url, token)
+    def delete_request_with_user_as_default(url, token)
       headers = {
         'Accept' =&gt; 'application/atom+xml',
         'Authorization' =&gt; %Q(AuthSub token=&quot;#{token}&quot;),
@@ -322,7 +327,7 @@ module YouTubeModel # :nodoc:
         'xmlns:yt' =&gt; 'http://gdata.youtube.com/schemas/2007' do
         xml.media :group do
           xml.tag! 'media:title', attrs[:title]
-          xml.media :description, attrs[:description], :type =&gt; 'plain'
+          xml.media :description, attrs[:content], :type =&gt; 'plain'
           xml.media :category, attrs[:category], :scheme =&gt; 'http://gdata.youtube.com/schemas/2007/categories.cat'
           xml.media :category, &quot;ytm_#{YT_CONFIG['developer_tag']}&quot;, :scheme =&gt; 'http://gdata.youtube.com/schemas/2007/developertags.cat'
           xml.tag! 'media:keywords', attrs[:keywords]</diff>
      <filename>lib/you_tube_model.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f798044e058340fd4cc19239b3a1facac4dbf102</id>
    </parent>
  </parents>
  <author>
    <name>vibha</name>
    <email>vibha@vinsol.com</email>
  </author>
  <url>http://github.com/edgarjs/youtube-model/commit/92f0fe7190f0f89509f7f522f2f7c81c51f114b4</url>
  <id>92f0fe7190f0f89509f7f522f2f7c81c51f114b4</id>
  <committed-date>2009-07-24T07:33:24-07:00</committed-date>
  <authored-date>2009-07-23T02:35:47-07:00</authored-date>
  <message>added gdata gem

Signed-off-by: Edgar J. Su&#225;rez &lt;edgar.js@gmail.com&gt;</message>
  <tree>5d605b8745fa7b8dfbd3dcb29ee528da8b90e2d0</tree>
  <committer>
    <name>Edgar J. Su&#225;rez</name>
    <email>edgar.js@gmail.com</email>
  </committer>
</commit>
