1
00:00:00,300 --> 00:00:04,320
In this video, I want to make five improvements to the program.

2
00:00:04,770 --> 00:00:09,030
The first improvement is besides the title and the description of the news.

3
00:00:09,030 --> 00:00:15,150
We also want to add a link so that the user can click on that link and read more about that particular

4
00:00:15,150 --> 00:00:15,750
news.

5
00:00:15,780 --> 00:00:17,070
That's the first improvement.

6
00:00:17,100 --> 00:00:25,380
The second improvement is we want to show less news because currently there's 100 of them, so perhaps

7
00:00:25,380 --> 00:00:27,120
20 should be better.

8
00:00:28,110 --> 00:00:34,530
The third improvement is we want to show only news in English because currently we have some other languages

9
00:00:34,530 --> 00:00:34,950
here.

10
00:00:34,980 --> 00:00:37,110
For example, this news in Europe.

11
00:00:38,430 --> 00:00:39,510
Fourth improvement.

12
00:00:39,510 --> 00:00:41,520
We want to add the subject to the email.

13
00:00:42,330 --> 00:00:44,130
And fifth, improvements.

14
00:00:44,140 --> 00:00:53,940
We want to have the category more dynamic because currently Tesla is hardcoded here in the URL, so

15
00:00:53,940 --> 00:00:58,050
we might want to also have the possibility to show other topics.

16
00:00:58,770 --> 00:01:01,200
Let's start with the first improvement links.

17
00:01:01,200 --> 00:01:07,850
To add links, you have to go in here where you construct that string.

18
00:01:07,860 --> 00:01:15,810
So we add the title, we add a brick line, we add the description, and then we add two brick lines.

19
00:01:15,810 --> 00:01:18,900
So the two brick lines are between the different news.

20
00:01:18,900 --> 00:01:27,540
But before we add the two lines, we want to add one other break line.

21
00:01:27,540 --> 00:01:34,320
So plus backslash n then plus article.

22
00:01:40,480 --> 00:01:42,880
You like that.

23
00:01:43,690 --> 00:01:44,620
So that should do it.

24
00:01:44,620 --> 00:01:48,130
But let me split this line because it's getting too long.

25
00:01:50,260 --> 00:01:51,430
So there as well.

26
00:01:52,670 --> 00:01:56,630
And I'll try the codes to make sure it works.

27
00:01:57,320 --> 00:01:58,910
And let's check the email.

28
00:02:00,260 --> 00:02:01,120
So there we go.

29
00:02:01,130 --> 00:02:10,039
We have links right now, the language to fix the language issue, you should add a new parameter to

30
00:02:10,039 --> 00:02:10,729
the query.

31
00:02:11,360 --> 00:02:12,590
What is the parameter?

32
00:02:12,620 --> 00:02:15,640
Well, the URL is made of different parts.

33
00:02:15,650 --> 00:02:20,300
It does have the code part first, which is this one in here.

34
00:02:20,840 --> 00:02:28,640
So let me show you the complete URL first as it was in the beginning without splitting it across multiple

35
00:02:28,640 --> 00:02:29,240
lines.

36
00:02:29,480 --> 00:02:31,290
So that's the complete URL.

37
00:02:31,310 --> 00:02:35,100
Now this is a core part up to here.

38
00:02:35,120 --> 00:02:37,070
So everything question mark.

39
00:02:37,250 --> 00:02:38,960
Then we have the parameters.

40
00:02:39,170 --> 00:02:41,480
So this here is a parameter.

41
00:02:41,480 --> 00:02:45,280
Q is the name of the parameter and Tesla is the value.

42
00:02:45,290 --> 00:02:49,940
And then we have this symbol which separates the parameters from each other.

43
00:02:50,570 --> 00:02:57,490
So we have the sort by parameter which defines how the news will be sorted.

44
00:02:57,500 --> 00:03:01,220
And so these are sorted now by published date.

45
00:03:01,250 --> 00:03:06,080
And then we have this symbol again to separate the other parameter from the previous one.

46
00:03:06,710 --> 00:03:13,160
We have the API key, the name of the parameter and the value, which is this value here of the API

47
00:03:13,160 --> 00:03:13,580
key.

48
00:03:14,240 --> 00:03:17,750
Now we can add all the parameters of the end here.

49
00:03:17,750 --> 00:03:24,770
You want to write the end symbol and then language is equal to n.

50
00:03:25,910 --> 00:03:29,780
So the parameter name and the value which is English.

51
00:03:29,780 --> 00:03:32,940
So that's also a parameter of this API.

52
00:03:32,960 --> 00:03:40,050
And you can find the parameters of this particular API in the news API dot org website.

53
00:03:40,070 --> 00:03:41,930
If you go to documentation.

54
00:03:43,300 --> 00:03:47,530
And you go to the end points and you go to the everything and points.

55
00:03:47,530 --> 00:03:51,290
And here you should find all the names for the parameters.

56
00:03:51,290 --> 00:03:55,630
So language is one of the parameters and you can pass these languages there.

57
00:03:57,300 --> 00:03:59,700
So we have sorted by as well.

58
00:04:01,570 --> 00:04:03,220
And other parameters, too.

59
00:04:03,250 --> 00:04:09,520
Q Which defines the topic, which is currently set to Tesla.

60
00:04:10,570 --> 00:04:15,060
So now let me prove the view here.

61
00:04:15,070 --> 00:04:17,230
So I'll split the string.

62
00:04:18,250 --> 00:04:27,690
And the parameters here and the next parameter after the symbol and the next one after the symbol.

63
00:04:27,700 --> 00:04:29,320
So this makes more sense.

64
00:04:29,320 --> 00:04:30,760
It's more readable, I think.

65
00:04:32,020 --> 00:04:33,970
So if I run this code now.

66
00:04:36,190 --> 00:04:38,800
And I check the email again.

67
00:04:40,340 --> 00:04:42,710
I should now see only news in English.

68
00:04:42,740 --> 00:04:44,320
Yep, that's the case.

69
00:04:44,330 --> 00:04:46,520
So it's seems to be working.

70
00:04:46,790 --> 00:04:51,420
So let's go back and let's limit the emails to 20 only four.

71
00:04:51,440 --> 00:04:54,470
That's all we have to do is go to contents article.

72
00:04:54,470 --> 00:04:57,740
So this is a list we're iterating over a list here.

73
00:04:58,040 --> 00:05:02,560
And this list has 100 items.

74
00:05:02,570 --> 00:05:05,390
But if you use this list, indexing.

75
00:05:07,580 --> 00:05:08,030
Sorry.

76
00:05:08,030 --> 00:05:09,790
It has to be the first 20.

77
00:05:10,220 --> 00:05:13,880
So 0 to 20 or just up to 20 the same.

78
00:05:14,180 --> 00:05:19,010
This now should give us only about 20 emails.

79
00:05:20,970 --> 00:05:21,750
Let's see.

80
00:05:23,130 --> 00:05:24,750
Yeah, it's about 20.

81
00:05:25,380 --> 00:05:27,300
So that's fewer news.

82
00:05:28,190 --> 00:05:28,790
Next.

83
00:05:28,790 --> 00:05:35,720
The subject and the subject of the email is part of the body of the email.

84
00:05:35,750 --> 00:05:43,700
So as you might remember from the previous email lectures in the previous apps, we used to add the

85
00:05:43,700 --> 00:05:49,060
subject on top of message of the email body.

86
00:05:49,070 --> 00:05:58,100
So that would be subject a column, a space, and then write something for the subject such as today's

87
00:05:58,100 --> 00:06:01,070
news Plus.

88
00:06:02,360 --> 00:06:07,270
A backslash, an operator, because that's the syntax.

89
00:06:07,280 --> 00:06:12,770
So the message should be something like.

90
00:06:13,160 --> 00:06:16,730
Subject to these.

91
00:06:18,820 --> 00:06:19,720
News.

92
00:06:22,880 --> 00:06:28,110
And then we have a brake line and there goes the body of the email, which is the news.

93
00:06:28,130 --> 00:06:30,530
So news number one, news number two, etc..

94
00:06:30,890 --> 00:06:41,300
So you get the idea, I suppose, and I'll split the line in here and try out the code.

95
00:06:44,270 --> 00:06:44,720
Let's see.

96
00:06:45,050 --> 00:06:47,360
That's where the subject is.

97
00:06:47,360 --> 00:06:48,650
So it's working.

98
00:06:48,800 --> 00:06:51,140
Everything seems to be looking fine.

99
00:06:51,500 --> 00:06:57,870
Lastly, the last change I want to make to this code is to fix the heart coding issue.

100
00:06:57,890 --> 00:07:04,730
So when something is injected into a value, for example, here, Tesla is part of this string that

101
00:07:04,730 --> 00:07:07,340
is known as hardcoded.

102
00:07:07,400 --> 00:07:12,170
So this is an hardcoded value to make this more dynamic.

103
00:07:12,650 --> 00:07:23,390
We could create a variable here, let's say topic and then you say Tesla here and then you convert this

104
00:07:23,390 --> 00:07:32,150
into an EV string and instead of Tesla there you have a placeholder and then you write a topic there.

105
00:07:32,960 --> 00:07:37,450
But be careful here because this string is spread across multiple lines.

106
00:07:37,460 --> 00:07:44,240
So actually the F should be at the line where the placeholder is located.

107
00:07:44,420 --> 00:07:46,010
So it should be in here.

108
00:07:46,190 --> 00:07:48,770
So with that, you can run the script.

109
00:07:50,610 --> 00:07:52,650
And check the email.

110
00:07:53,280 --> 00:07:54,950
And yeah, there we go.

111
00:07:54,960 --> 00:07:57,060
That's still news about Tesla.

112
00:07:58,290 --> 00:07:59,670
So it's working fine.

113
00:08:01,040 --> 00:08:05,530
So that gives us some more control over what we want to display here.

114
00:08:05,540 --> 00:08:12,290
So it's better to change the the variable name in here instead of modifying the value of the string

115
00:08:12,290 --> 00:08:13,010
itself.

116
00:08:13,880 --> 00:08:19,070
So with that, we have done all the five improvements, so we are ready to commit the changes.

117
00:08:20,180 --> 00:08:21,950
So that's the 28.

118
00:08:23,270 --> 00:08:28,550
And you might want to mention here all the improvements add links.

119
00:08:30,180 --> 00:08:34,710
Specify language limits use.

120
00:08:36,440 --> 00:08:38,299
At subject.

121
00:08:39,460 --> 00:08:41,919
And control the category.

122
00:08:42,070 --> 00:08:46,690
Now it's a better idea to actually make a commit.

123
00:08:46,690 --> 00:08:50,320
So whenever you want to make one single change.

124
00:08:50,320 --> 00:08:55,660
So in this case, it would be better if we added the links as we did here.

125
00:08:55,900 --> 00:09:01,060
So after we did this change, we should have committed the changes and then we did the other change

126
00:09:01,060 --> 00:09:02,620
and we commit the other change.

127
00:09:02,620 --> 00:09:07,660
And in each commit message we only write that particular change that we did.

128
00:09:07,840 --> 00:09:13,120
However, I'm not doing that because it would be too much for doing it in a video.

129
00:09:13,330 --> 00:09:16,390
Those would be too many pauses.

130
00:09:17,440 --> 00:09:20,410
So that's something to keep in mind.

131
00:09:20,440 --> 00:09:25,840
You want to commit whenever you make a change and then you test the program.

132
00:09:25,840 --> 00:09:28,420
If it's working and if it's working, then you commit.

133
00:09:28,670 --> 00:09:28,960
Yeah.

134
00:09:28,960 --> 00:09:29,980
So let's commit.

135
00:09:30,490 --> 00:09:32,110
And that's for this video.

136
00:09:32,590 --> 00:09:33,550
Thank you for following.

