Modify

Ticket #1 (closed idea: fixed)

Opened 4 years ago

Last modified 4 years ago

idee correction videolink (methode youtube)

Reported by: thaeron@… Owned by: thaeron
Priority: minor Milestone:
Component: modules Version:
Keywords: Cc:

Description

Depuis quelques temps le module videolink ne fonctionne plus pour youtube. Le module passait par kissyoutube qui ne fonctionne plus.

Technique à implémenter dans NS pour être indépendant : DL de la page indiquée dans le code de la page il y a :

var swfArgs = {hl:'fr',BASE_YT_URL:'http://fr.youtube.com/',video_id:'eFnvxOmm6tc',l:'171',t:'OEgsToPDskIAcJ4yneZwaj2UXs8u90vJ',sk:'QJ97ZJPxFU44EmHNlVfGYAC'};

ou encore

var fullscreenUrl = '/watch_fullscreen?video_id=eFnvxOmm6tc&l=171&t=OEgsToPDskIAcJ4yneZwaj2UXs8u90vJ&sk=QJ97ZJPxFU44EmHNlVfGYAC&fs=1&title=Un p\'tit café ???!!! - Oldelaf & Monsieur D - Café';

A partir de ces éléments on peut avoir l'url pour DL la vidéo :  http://fr.youtube.com/get_video.php?video_id=eFnvxOmm6tc&t=OEgsToPDskIAcJ4yneZwaj2UXs8u90vJ&sk=QJ97ZJPxFU44EmHNlVfGYAC

Note : je ne sais pas si t & sk sont nécessaires ou si seulement 1 seul est nécessaire.

Attachments

videolink-patch.diff Download (2.7 KB) - added by thaeron 4 years ago.

Change History

comment:1 Changed 4 years ago by thaeron

  • Status changed from new to assigned

comment:2 Changed 4 years ago by thaeron

  • Type changed from enhancement to idea

comment:3 in reply to: ↑ description Changed 4 years ago by thaeron

  • Status changed from assigned to closed
  • Resolution set to fixed

idée appliquée. Version 0.2.1 de videolink.

--- src/modules/videolink.c	(révision 19)
+++ src/modules/videolink.c	(copie de travail)
@@ -10,7 +10,7 @@
   bot_set_auteur_module ("Thaeron");
   bot_set_desc_module ("Choppe le lien d'une vidéo youtube/dailymotion");
   bot_set_ident_module ("videolink");
-  bot_set_version_module ("0.2");
+  bot_set_version_module ("0.2.1");
   bot_add_cmd_handler ("²videolink", "videolink_public");
 }
 
@@ -61,37 +61,53 @@
 
 int parse_youtube (requete *req)
 {
-  char *pro_data, *data, *url_tmp;
+	char *data, *t_sk, *v_id, *ptr, *ptr2;
+	int n;
 
-  data = strstr (req->buffer, "Download Now");
-  if (!data)
-    {
-      bot_send_privmsgf (req->ou, "URL incorrecte");
-      return (0);
-    }
-  if (data - req->buffer > 5)
-    	data -= 2;
-  else
-  {
-      bot_send_privmsgf (req->ou, "Problème lors de la récupération du lien");
-      return (0);
-  } 
-  
-  for (pro_data = data - 1; *pro_data != '\"' && pro_data != req->buffer; pro_data--);
-  if (pro_data == req->buffer)
-  {
-      bot_send_privmsgf (req->ou, "Problème lors de la récupération du lien");
-      return (0);
-  }
-  pro_data++;
-  url_tmp = (char *) malloc (sizeof (char) * (data - pro_data + 1));
-  strncpy (url_tmp, pro_data, data - pro_data);
-  url_tmp[data - pro_data] = 0;
+	data = strstr (req->buffer, "var fullscreenUrl =");
+	if (!data)
+	{
+		bot_send_privmsg (req->ou, "Impossible de récupérer les éléments de l'url");
+		return (0);
+	}
+	
+	ptr = strstr (data, "video_id=");
+	if (!ptr)
+		return (0);
 
-  bot_send_privmsgf (req->ou, "Vidéo : %s", url_tmp);
+	ptr2 = strchr (data, '&');
+	if (!ptr2 || ptr2 - ptr > 20)
+		return (0);
+	
+	n = ptr2 - ptr;
+	v_id = (char *) malloc (n + 1);
+	strncpy (v_id, ptr, n);
+	v_id[n] = 0;
+	
+	ptr = strstr (ptr2, "&t=");
+	if (!ptr)
+	{
+		free (v_id);
+		return (0);
+	}
 
-  free (url_tmp);
-  return (0);
+	ptr2 = strstr (ptr, "&fs=1");
+	if (!ptr2 || (ptr2 - ptr) > 100)
+	{
+		free (v_id);
+		return (0);
+	}
+
+	n = ptr2 - ptr;
+	t_sk = (char *) malloc (n + 1);
+	strncpy (t_sk, ptr, n);
+	t_sk[n] = 0;
+	  
+	bot_send_privmsgf (req->ou, "Vidéo : http://fr.youtube.com/get_video.php?%s%s", v_id, t_sk);
+	free (t_sk);  
+	free (v_id);
+	
+	return (0);
 }
 
 int
@@ -125,7 +141,7 @@
 	  return 0;
 	}
       type_video = VIDEOLINK_YOUTUBE;
-      req_buf = strf ("GET %s HTTP/1.0\nHost: www.kissyoutube.com\n\n", p_tmp + 11);
+      req_buf = strf ("GET %s HTTP/1.0\nHost: www.youtube.com\n\n", p_tmp + 11);
     }
   else
     {
@@ -149,7 +165,7 @@
   req_head->divers[0] = type_video;
   
   if (type_video == VIDEOLINK_YOUTUBE)
-      connexion_tcp ("www.kissyoutube.com", 80);
+      connexion_tcp ("www.youtube.com", 80);
        
   else if (type_video == VIDEOLINK_DAILYMOTION)
       connexion_tcp ("www.dailymotion.com", 80);

Changed 4 years ago by thaeron

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.